@@ -20,8 +20,8 @@ public actor Datastore<
2020 let version : Version
2121 let encoder : ( _ instance: CodedType ) async throws -> Data
2222 let decoders : [ Version : ( _ data: Data ) async throws -> CodedType ]
23- let directIndexes : [ IndexPath < CodedType > ]
24- let computedIndexes : [ IndexPath < CodedType > ]
23+ let directIndexes : [ IndexPath < CodedType , _AnyIndexed > ]
24+ let computedIndexes : [ IndexPath < CodedType , _AnyIndexed > ]
2525
2626 var updatedDescriptor : DatastoreDescriptor ?
2727
@@ -31,8 +31,8 @@ public actor Datastore<
3131 fileprivate var storeMigrationStatus : TaskStatus = . waiting
3232 fileprivate var storeMigrationProgressHandlers : [ ProgressHandler ] = [ ]
3333
34- fileprivate var indexMigrationStatus : [ IndexPath < CodedType > : TaskStatus ] = [ : ]
35- fileprivate var indexMigrationProgressHandlers : [ IndexPath < CodedType > : ProgressHandler ] = [ : ]
34+ fileprivate var indexMigrationStatus : [ IndexPath < CodedType , _AnyIndexed > : TaskStatus ] = [ : ]
35+ fileprivate var indexMigrationProgressHandlers : [ IndexPath < CodedType , _AnyIndexed > : ProgressHandler ] = [ : ]
3636
3737 public init (
3838 persistence: some Persistence < AccessMode > ,
@@ -42,8 +42,8 @@ public actor Datastore<
4242 identifierType: IdentifierType . Type ,
4343 encoder: @escaping ( _ instance: CodedType ) async throws -> Data ,
4444 decoders: [ Version : ( _ data: Data ) async throws -> CodedType ] ,
45- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
46- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
45+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
46+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
4747 configuration: Configuration = . init( )
4848 ) where AccessMode == ReadWrite {
4949 self . persistence = persistence
@@ -62,8 +62,8 @@ public actor Datastore<
6262 codedType: CodedType . Type = CodedType . self,
6363 identifierType: IdentifierType . Type ,
6464 decoders: [ Version : ( _ data: Data ) async throws -> CodedType ] ,
65- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
66- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
65+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
66+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
6767 configuration: Configuration = . init( )
6868 ) where AccessMode == ReadOnly {
6969 self . persistence = persistence
@@ -172,7 +172,7 @@ extension Datastore where AccessMode == ReadWrite {
172172 /// - index: The index to migrate.
173173 /// - minimumVersion: The minimum valid version for an index to not be migrated.
174174 /// - progressHandler: A closure that will be regularly called with progress during the migration. If no migration needs to occur, it won't be called, so setup and tear down any UI within the handler.
175- public func migrate( index: IndexPath < CodedType > , ifLessThan minimumVersion: Version , progressHandler: ProgressHandler ? = nil ) async throws {
175+ public func migrate( index: IndexPath < CodedType , _AnyIndexed > , ifLessThan minimumVersion: Version , progressHandler: ProgressHandler ? = nil ) async throws {
176176 try await persistence. _withTransaction ( options: [ ] ) { transaction in
177177 guard
178178 /// If we have no descriptor, then no data exists to be migrated.
@@ -214,7 +214,7 @@ extension Datastore where AccessMode == ReadWrite {
214214 }
215215 }
216216
217- func migrate( index: IndexPath < CodedType > , progressHandler: ProgressHandler ? = nil ) async throws {
217+ func migrate( index: IndexPath < CodedType , _AnyIndexed > , progressHandler: ProgressHandler ? = nil ) async throws {
218218 // TODO: Migrate just that index, use indexMigrationStatus and indexMigrationProgressHandlers to record progress.
219219 }
220220
@@ -308,7 +308,7 @@ extension Datastore {
308308 public nonisolated func load< IndexedValue: Indexable > (
309309 _ range: some IndexRangeExpression < IndexedValue > ,
310310 order: RangeOrder = . ascending,
311- from indexPath: IndexPath < CodedType >
311+ from indexPath: IndexPath < CodedType , _SomeIndexed < IndexedValue > >
312312 ) -> some TypedAsyncSequence < CodedType > {
313313 let a : AsyncThrowingBackpressureStream < CodedType > = AsyncThrowingBackpressureStream { provider in
314314 try await self . warmupIfNeeded ( )
@@ -353,23 +353,23 @@ extension Datastore {
353353 public nonisolated func load< IndexedValue: Indexable > (
354354 _ range: IndexRange < IndexedValue > ,
355355 order: RangeOrder = . ascending,
356- from keypath: IndexPath < CodedType >
356+ from keypath: IndexPath < CodedType , _SomeIndexed < IndexedValue > >
357357 ) -> some TypedAsyncSequence < CodedType > {
358358 load ( range, order: order, from: keypath)
359359 }
360360
361- public nonisolated func load(
361+ public nonisolated func load< IndexedValue : Indexable > (
362362 _ range: Swift . UnboundedRange ,
363363 order: RangeOrder = . ascending,
364- from keypath: IndexPath < CodedType >
364+ from keypath: IndexPath < CodedType , _SomeIndexed < IndexedValue > >
365365 ) -> some TypedAsyncSequence < CodedType > {
366- load ( IndexRange < Int > ( ) , order: order, from: keypath)
366+ load ( IndexRange < IndexedValue > ( ) , order: order, from: keypath)
367367 }
368368
369369 public nonisolated func load< IndexedValue: Indexable > (
370370 _ value: IndexedValue ,
371371 order: RangeOrder = . ascending,
372- from keypath: IndexPath < CodedType >
372+ from keypath: IndexPath < CodedType , _SomeIndexed < IndexedValue > >
373373 ) -> some TypedAsyncSequence < CodedType > {
374374 load ( value... value, order: order, from: keypath)
375375 }
@@ -781,8 +781,8 @@ extension Datastore where AccessMode == ReadWrite {
781781 encoder: JSONEncoder = JSONEncoder ( ) ,
782782 decoder: JSONDecoder = JSONDecoder ( ) ,
783783 migrations: [ Version : ( _ data: Data , _ decoder: JSONDecoder ) async throws -> CodedType ] ,
784- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
785- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
784+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
785+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
786786 configuration: Configuration = . init( )
787787 ) -> Self {
788788 self . init (
@@ -811,8 +811,8 @@ extension Datastore where AccessMode == ReadWrite {
811811 identifierType: IdentifierType . Type ,
812812 outputFormat: PropertyListSerialization . PropertyListFormat = . binary,
813813 migrations: [ Version : ( _ data: Data , _ decoder: PropertyListDecoder ) async throws -> CodedType ] ,
814- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
815- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
814+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
815+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
816816 configuration: Configuration = . init( )
817817 ) -> Self {
818818 let encoder = PropertyListEncoder ( )
@@ -848,8 +848,8 @@ extension Datastore where AccessMode == ReadOnly {
848848 identifierType: IdentifierType . Type ,
849849 decoder: JSONDecoder = JSONDecoder ( ) ,
850850 migrations: [ Version : ( _ data: Data , _ decoder: JSONDecoder ) async throws -> CodedType ] ,
851- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
852- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
851+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
852+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
853853 configuration: Configuration = . init( )
854854 ) -> Self {
855855 self . init (
@@ -876,8 +876,8 @@ extension Datastore where AccessMode == ReadOnly {
876876 codedType: CodedType . Type = CodedType . self,
877877 identifierType: IdentifierType . Type ,
878878 migrations: [ Version : ( _ data: Data , _ decoder: PropertyListDecoder ) async throws -> CodedType ] ,
879- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
880- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
879+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
880+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
881881 configuration: Configuration = . init( )
882882 ) -> Self {
883883 let decoder = PropertyListDecoder ( )
@@ -910,8 +910,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
910910 codedType: CodedType . Type = CodedType . self,
911911 encoder: @escaping ( _ object: CodedType ) async throws -> Data ,
912912 decoders: [ Version : ( _ data: Data ) async throws -> CodedType ] ,
913- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
914- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
913+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
914+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
915915 configuration: Configuration = . init( )
916916 ) {
917917 self . init (
@@ -936,8 +936,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
936936 encoder: JSONEncoder = JSONEncoder ( ) ,
937937 decoder: JSONDecoder = JSONDecoder ( ) ,
938938 migrations: [ Version : ( _ data: Data , _ decoder: JSONDecoder ) async throws -> CodedType ] ,
939- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
940- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
939+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
940+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
941941 configuration: Configuration = . init( )
942942 ) -> Self {
943943 self . JSONStore (
@@ -962,8 +962,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
962962 codedType: CodedType . Type = CodedType . self,
963963 outputFormat: PropertyListSerialization . PropertyListFormat = . binary,
964964 migrations: [ Version : ( _ data: Data , _ decoder: PropertyListDecoder ) async throws -> CodedType ] ,
965- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
966- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
965+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
966+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
967967 configuration: Configuration = . init( )
968968 ) -> Self {
969969 self . propertyListStore (
@@ -988,8 +988,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
988988 version: Version ,
989989 codedType: CodedType . Type = CodedType . self,
990990 decoders: [ Version : ( _ data: Data ) async throws -> CodedType ] ,
991- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
992- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
991+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
992+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
993993 configuration: Configuration = . init( )
994994 ) {
995995 self . init (
@@ -1012,8 +1012,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
10121012 codedType: CodedType . Type = CodedType . self,
10131013 decoder: JSONDecoder = JSONDecoder ( ) ,
10141014 migrations: [ Version : ( _ data: Data , _ decoder: JSONDecoder ) async throws -> CodedType ] ,
1015- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
1016- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
1015+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
1016+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
10171017 configuration: Configuration = . init( )
10181018 ) -> Self {
10191019 self . readOnlyJSONStore (
@@ -1036,8 +1036,8 @@ extension Datastore where CodedType: Identifiable, IdentifierType == CodedType.I
10361036 version: Version ,
10371037 codedType: CodedType . Type = CodedType . self,
10381038 migrations: [ Version : ( _ data: Data , _ decoder: PropertyListDecoder ) async throws -> CodedType ] ,
1039- directIndexes: [ IndexPath < CodedType > ] = [ ] ,
1040- computedIndexes: [ IndexPath < CodedType > ] = [ ] ,
1039+ directIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
1040+ computedIndexes: [ IndexPath < CodedType , _AnyIndexed > ] = [ ] ,
10411041 configuration: Configuration = . init( )
10421042 ) -> Self {
10431043 self . readOnlyPropertyListStore (
0 commit comments