@@ -18,48 +18,35 @@ public protocol PackageCollectionsStorage {
18
18
///
19
19
/// - Parameters:
20
20
/// - collection: The `PackageCollection`
21
- /// - callback: The closure to invoke when result becomes available
22
- @available ( * , noasync, message: " Use the async alternative " )
23
- func put( collection: PackageCollectionsModel . Collection ,
24
- callback: @escaping ( Result < PackageCollectionsModel . Collection , Error > ) -> Void )
21
+ func put( collection: PackageCollectionsModel . Collection ) async throws -> PackageCollectionsModel . Collection
25
22
26
23
/// Removes `PackageCollection` from storage.
27
24
///
28
25
/// - Parameters:
29
26
/// - identifier: The identifier of the `PackageCollection`
30
- /// - callback: The closure to invoke when result becomes available
31
- @available ( * , noasync, message: " Use the async alternative " )
32
- func remove( identifier: PackageCollectionsModel . CollectionIdentifier ,
33
- callback: @escaping ( Result < Void , Error > ) -> Void )
27
+ func remove( identifier: PackageCollectionsModel . CollectionIdentifier ) async throws
34
28
35
29
/// Returns `PackageCollection` for the given identifier.
36
30
///
37
31
/// - Parameters:
38
32
/// - identifier: The identifier of the `PackageCollection`
39
- /// - callback: The closure to invoke when result becomes available
40
- @available ( * , noasync, message: " Use the async alternative " )
41
- func get( identifier: PackageCollectionsModel . CollectionIdentifier ,
42
- callback: @escaping ( Result < PackageCollectionsModel . Collection , Error > ) -> Void )
33
+ func get( identifier: PackageCollectionsModel . CollectionIdentifier ) async throws -> PackageCollectionsModel . Collection
43
34
44
35
/// Returns `PackageCollection`s for the given identifiers, or all if none specified.
45
36
///
46
37
/// - Parameters:
47
38
/// - identifiers: Optional. The identifiers of the `PackageCollection`
48
- /// - callback: The closure to invoke when result becomes available
49
- @available ( * , noasync, message: " Use the async alternative " )
50
- func list( identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
51
- callback: @escaping ( Result < [ PackageCollectionsModel . Collection ] , Error > ) -> Void )
39
+ func list( identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ) async throws -> [ PackageCollectionsModel . Collection ]
52
40
53
41
/// Returns `PackageSearchResult` for the given search criteria.
54
42
///
55
43
/// - Parameters:
56
44
/// - identifiers: Optional. The identifiers of the `PackageCollection`s
57
45
/// - query: The search query expression
58
- /// - callback: The closure to invoke when result becomes available
59
- @available ( * , noasync, message: " Use the async alternative " )
60
- func searchPackages( identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
61
- query: String ,
62
- callback: @escaping ( Result < PackageCollectionsModel . PackageSearchResult , Error > ) -> Void )
46
+ func searchPackages(
47
+ identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
48
+ query: String
49
+ ) async throws -> PackageCollectionsModel . PackageSearchResult
63
50
64
51
/// Returns packages for the given package identity.
65
52
///
@@ -68,72 +55,20 @@ public protocol PackageCollectionsStorage {
68
55
/// - Parameters:
69
56
/// - identifier: The package identifier
70
57
/// - collectionIdentifiers: Optional. The identifiers of the `PackageCollection`s
71
- /// - callback: The closure to invoke when result becomes available
72
- @available ( * , noasync, message: " Use the async alternative " )
73
- func findPackage( identifier: PackageIdentity ,
74
- collectionIdentifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
75
- callback: @escaping ( Result < ( packages: [ PackageCollectionsModel . Package ] , collections: [ PackageCollectionsModel . CollectionIdentifier ] ) , Error > ) -> Void )
58
+ func findPackage(
59
+ identifier: PackageIdentity ,
60
+ collectionIdentifiers: [ PackageCollectionsModel . CollectionIdentifier ] ?
61
+ ) async throws -> ( packages: [ PackageCollectionsModel . Package ] , collections: [ PackageCollectionsModel . CollectionIdentifier ] )
76
62
77
63
/// Returns `TargetSearchResult` for the given search criteria.
78
64
///
79
65
/// - Parameters:
80
66
/// - identifiers: Optional. The identifiers of the `PackageCollection`
81
67
/// - query: The search query expression
82
68
/// - type: The search type
83
- /// - callback: The closure to invoke when result becomes available
84
- @available ( * , noasync, message: " Use the async alternative " )
85
- func searchTargets( identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
86
- query: String ,
87
- type: PackageCollectionsModel . TargetSearchType ,
88
- callback: @escaping ( Result < PackageCollectionsModel . TargetSearchResult , Error > ) -> Void )
89
- }
90
-
91
- public extension PackageCollectionsStorage {
92
- func put( collection: PackageCollectionsModel . Collection ) async throws -> PackageCollectionsModel . Collection {
93
- try await safe_async {
94
- self . put ( collection: collection, callback: $0)
95
- }
96
- }
97
- func remove( identifier: PackageCollectionsModel . CollectionIdentifier ) async throws {
98
- try await safe_async {
99
- self . remove ( identifier: identifier, callback: $0)
100
- }
101
- }
102
- func get( identifier: PackageCollectionsModel . CollectionIdentifier ) async throws -> PackageCollectionsModel . Collection {
103
- try await safe_async {
104
- self . get ( identifier: identifier, callback: $0)
105
- }
106
- }
107
- func list( identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? = nil ) async throws -> [ PackageCollectionsModel . Collection ] {
108
- try await safe_async {
109
- self . list ( identifiers: identifiers, callback: $0)
110
- }
111
- }
112
-
113
- func searchPackages(
114
- identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? = nil ,
115
- query: String
116
- ) async throws -> PackageCollectionsModel . PackageSearchResult {
117
- try await safe_async {
118
- self . searchPackages ( identifiers: identifiers, query: query, callback: $0)
119
- }
120
- }
121
- func findPackage(
122
- identifier: PackageIdentity ,
123
- collectionIdentifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? = nil
124
- ) async throws -> ( packages: [ PackageCollectionsModel . Package ] , collections: [ PackageCollectionsModel . CollectionIdentifier ] ) {
125
- try await safe_async {
126
- self . findPackage ( identifier: identifier, collectionIdentifiers: collectionIdentifiers, callback: $0)
127
- }
128
- }
129
-
130
69
func searchTargets(
131
- identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? = nil ,
70
+ identifiers: [ PackageCollectionsModel . CollectionIdentifier ] ? ,
132
71
query: String ,
133
72
type: PackageCollectionsModel . TargetSearchType
134
- ) async throws -> PackageCollectionsModel . TargetSearchResult {
135
- try await safe_async {
136
- self . searchTargets ( identifiers: identifiers, query: query, type: type, callback: $0)
137
- }
138
- }
73
+ ) async throws -> PackageCollectionsModel . TargetSearchResult
139
74
}
0 commit comments