LocalData/Sources/LocalData/Models/AnyStorageKey.swift
Matt Bruce 05ea1a9798 Update Models, Services + docs
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(-)
2026-01-18 14:53:28 -06:00

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)
}
}