Add database change notification

This commit is contained in:
2025-11-09 17:23:08 +02:00
parent 5bbb722b20
commit df17d21ec4
6 changed files with 84 additions and 112 deletions

View File

@@ -9,8 +9,8 @@ import DataLiteCore
/// stores version data using the SQLite `PRAGMA user_version` mechanism. This approach is simple,
/// efficient, and requires no additional tables.
///
/// The generic ``Version`` type must conform to both ``VersionRepresentable`` and
/// `RawRepresentable`, with `RawValue == UInt32`. This enables conversion between stored integer
/// The generic `Version` type must conform to both ``VersionRepresentable`` and `RawRepresentable`,
/// with `RawValue == UInt32`. This enables conversion between stored integer
/// values and the applications semantic version type.
///
/// ## Topics
@@ -26,10 +26,9 @@ import DataLiteCore
public final class UserVersionStorage<
Version: VersionRepresentable & RawRepresentable
>: Sendable, VersionStorage where Version.RawValue == UInt32 {
/// Errors related to reading or decoding the stored version.
public enum Error: Swift.Error {
/// The stored `user_version` value could not be decoded into a valid ``Version``.
/// The stored `user_version` value could not be decoded into a valid `Version`.
///
/// - Parameter value: The invalid raw `UInt32` value.
case invalidStoredVersion(UInt32)
@@ -44,7 +43,7 @@ public final class UserVersionStorage<
/// Returns the current schema version stored in the `user_version` field.
///
/// Reads the `PRAGMA user_version` value and attempts to decode it into a valid ``Version``.
/// Reads the `PRAGMA user_version` value and attempts to decode it into a valid `Version`.
/// If decoding fails, this method throws an error.
///
/// - Parameter connection: The active database connection.
@@ -62,7 +61,7 @@ public final class UserVersionStorage<
/// Stores the specified schema version in the `user_version` field.
///
/// Updates the SQLite `PRAGMA user_version` value with the raw `UInt32` representation of the
/// provided ``Version``.
/// provided `Version`.
///
/// - Parameters:
/// - connection: The active database connection.