Summary: - Sources: Models, Services - Docs: README - Added symbols: func migrate, func registerCatalog, func migrateAllRegisteredKeys - Removed symbols: func registerCatalog Stats: - 3 files changed, 84 insertions(+), 1 deletion(-)
21 lines
645 B
Swift
21 lines
645 B
Swift
public struct AnyStorageKey: Sendable {
|
|
public let descriptor: StorageKeyDescriptor
|
|
private let migrateAction: @Sendable (StorageRouter) async throws -> Void
|
|
|
|
public init<Key: StorageKey>(_ key: Key) {
|
|
self.descriptor = .from(key)
|
|
self.migrateAction = { router in
|
|
try await router.migrate(for: key)
|
|
}
|
|
}
|
|
|
|
public static func key<Key: StorageKey>(_ key: Key) -> AnyStorageKey {
|
|
AnyStorageKey(key)
|
|
}
|
|
|
|
/// Internal use: Triggers the migration logic for this key.
|
|
internal func migrate(on router: StorageRouter) async throws {
|
|
try await migrateAction(router)
|
|
}
|
|
}
|