@@ -19,14 +19,14 @@ extension CoreDataRepository {
1919 }
2020
2121 @inlinable
22- public func aggregate< Value: Numeric > (
22+ public func aggregate< Value> (
2323 function: AggregateFunction ,
2424 predicate: NSPredicate ,
2525 entityDesc: NSEntityDescription ,
2626 attributeDesc: NSAttributeDescription ,
2727 groupBy: NSAttributeDescription ? = nil ,
2828 as valueType: Value . Type
29- ) async -> Result < Value , CoreDataError > {
29+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
3030 switch function {
3131 case . count:
3232 await count ( predicate: predicate, entityDesc: entityDesc, as: valueType)
@@ -46,13 +46,13 @@ extension CoreDataRepository {
4646
4747 /// Get the average of a managed object's numeric property for all instances that satisfy the predicate.
4848 @inlinable
49- public func average< Value: Numeric > (
49+ public func average< Value> (
5050 predicate: NSPredicate ,
5151 entityDesc: NSEntityDescription ,
5252 attributeDesc: NSAttributeDescription ,
5353 groupBy: NSAttributeDescription ? = nil ,
5454 as _: Value . Type
55- ) async -> Result < Value , CoreDataError > {
55+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
5656 await Self . send (
5757 function: . average,
5858 context: context,
@@ -65,13 +65,13 @@ extension CoreDataRepository {
6565
6666 /// Subscribe to the average of a managed object's numeric property for all instances that satisfy the predicate.
6767 @inlinable
68- public func averageSubscription< Value: Numeric > (
68+ public func averageSubscription< Value> (
6969 predicate: NSPredicate ,
7070 entityDesc: NSEntityDescription ,
7171 attributeDesc: NSAttributeDescription ,
7272 groupBy: NSAttributeDescription ? = nil ,
7373 as _: Value . Type
74- ) -> AsyncStream < Result < Value , CoreDataError > > {
74+ ) -> AsyncStream < Result < Value , CoreDataError > > where Value : Numeric , Value : Sendable {
7575 AsyncStream { continuation in
7676 let subscription = AggregateSubscription (
7777 function: . average,
@@ -91,13 +91,13 @@ extension CoreDataRepository {
9191
9292 /// Subscribe to the average of a managed object's numeric property for all instances that satisfy the predicate.
9393 @inlinable
94- public func averageThrowingSubscription< Value: Numeric > (
94+ public func averageThrowingSubscription< Value> (
9595 predicate: NSPredicate ,
9696 entityDesc: NSEntityDescription ,
9797 attributeDesc: NSAttributeDescription ,
9898 groupBy: NSAttributeDescription ? = nil ,
9999 as _: Value . Type
100- ) -> AsyncThrowingStream < Value , Error > {
100+ ) -> AsyncThrowingStream < Value , Error > where Value : Numeric , Value : Sendable {
101101 AsyncThrowingStream { continuation in
102102 let subscription = AggregateThrowingSubscription (
103103 function: . average,
@@ -119,11 +119,11 @@ extension CoreDataRepository {
119119
120120 /// Get the count or quantity of managed object instances that satisfy the predicate.
121121 @inlinable
122- public func count< Value: Numeric > (
122+ public func count< Value> (
123123 predicate: NSPredicate ,
124124 entityDesc: NSEntityDescription ,
125125 as _: Value . Type
126- ) async -> Result < Value , CoreDataError > {
126+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
127127 await context. performInScratchPad { scratchPad in
128128 do {
129129 let request = try NSFetchRequest< NSDictionary>
@@ -140,11 +140,11 @@ extension CoreDataRepository {
140140
141141 /// Subscribe to the count or quantity of managed object instances that satisfy the predicate.
142142 @inlinable
143- public func countSubscription< Value: Numeric > (
143+ public func countSubscription< Value> (
144144 predicate: NSPredicate ,
145145 entityDesc: NSEntityDescription ,
146146 as _: Value . Type
147- ) -> AsyncStream < Result < Value , CoreDataError > > {
147+ ) -> AsyncStream < Result < Value , CoreDataError > > where Value : Numeric , Value : Sendable {
148148 AsyncStream { continuation in
149149 let subscription = CountSubscription (
150150 context: context. childContext ( ) ,
@@ -161,11 +161,11 @@ extension CoreDataRepository {
161161
162162 /// Subscribe to the count or quantity of managed object instances that satisfy the predicate.
163163 @inlinable
164- public func countThrowingSubscription< Value: Numeric > (
164+ public func countThrowingSubscription< Value> (
165165 predicate: NSPredicate ,
166166 entityDesc: NSEntityDescription ,
167167 as _: Value . Type
168- ) -> AsyncThrowingStream < Value , Error > {
168+ ) -> AsyncThrowingStream < Value , Error > where Value : Numeric , Value : Sendable {
169169 AsyncThrowingStream { continuation in
170170 let subscription = CountThrowingSubscription (
171171 context: context. childContext ( ) ,
@@ -184,13 +184,13 @@ extension CoreDataRepository {
184184
185185 /// Get the max or maximum of a managed object's numeric property for all instances that satisfy the predicate.
186186 @inlinable
187- public func max< Value: Numeric > (
187+ public func max< Value> (
188188 predicate: NSPredicate ,
189189 entityDesc: NSEntityDescription ,
190190 attributeDesc: NSAttributeDescription ,
191191 groupBy: NSAttributeDescription ? = nil ,
192192 as _: Value . Type
193- ) async -> Result < Value , CoreDataError > {
193+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
194194 await Self . send (
195195 function: . max,
196196 context: context,
@@ -204,13 +204,13 @@ extension CoreDataRepository {
204204 /// Subscribe to the max or maximum of a managed object's numeric property for all instances that satisfy the
205205 /// predicate.
206206 @inlinable
207- public func maxSubscription< Value: Numeric > (
207+ public func maxSubscription< Value> (
208208 predicate: NSPredicate ,
209209 entityDesc: NSEntityDescription ,
210210 attributeDesc: NSAttributeDescription ,
211211 groupBy: NSAttributeDescription ? = nil ,
212212 as _: Value . Type
213- ) -> AsyncStream < Result < Value , CoreDataError > > {
213+ ) -> AsyncStream < Result < Value , CoreDataError > > where Value : Numeric , Value : Sendable {
214214 AsyncStream { continuation in
215215 let subscription = AggregateSubscription (
216216 function: . max,
@@ -231,13 +231,13 @@ extension CoreDataRepository {
231231 /// Subscribe to the max or maximum of a managed object's numeric property for all instances that satisfy the
232232 /// predicate.
233233 @inlinable
234- public func maxThrowingSubscription< Value: Numeric > (
234+ public func maxThrowingSubscription< Value> (
235235 predicate: NSPredicate ,
236236 entityDesc: NSEntityDescription ,
237237 attributeDesc: NSAttributeDescription ,
238238 groupBy: NSAttributeDescription ? = nil ,
239239 as _: Value . Type
240- ) -> AsyncThrowingStream < Value , Error > {
240+ ) -> AsyncThrowingStream < Value , Error > where Value : Numeric , Value : Sendable {
241241 AsyncThrowingStream { continuation in
242242 let subscription = AggregateThrowingSubscription (
243243 function: . max,
@@ -259,13 +259,13 @@ extension CoreDataRepository {
259259
260260 /// Get the min or minimum of a managed object's numeric property for all instances that satisfy the predicate.
261261 @inlinable
262- public func min< Value: Numeric > (
262+ public func min< Value> (
263263 predicate: NSPredicate ,
264264 entityDesc: NSEntityDescription ,
265265 attributeDesc: NSAttributeDescription ,
266266 groupBy: NSAttributeDescription ? = nil ,
267267 as _: Value . Type
268- ) async -> Result < Value , CoreDataError > {
268+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
269269 await Self . send (
270270 function: . min,
271271 context: context,
@@ -279,13 +279,13 @@ extension CoreDataRepository {
279279 /// Subscribe to the min or minimum of a managed object's numeric property for all instances that satisfy the
280280 /// predicate.
281281 @inlinable
282- public func minSubscription< Value: Numeric > (
282+ public func minSubscription< Value> (
283283 predicate: NSPredicate ,
284284 entityDesc: NSEntityDescription ,
285285 attributeDesc: NSAttributeDescription ,
286286 groupBy: NSAttributeDescription ? = nil ,
287287 as _: Value . Type
288- ) -> AsyncStream < Result < Value , CoreDataError > > {
288+ ) -> AsyncStream < Result < Value , CoreDataError > > where Value : Numeric , Value : Sendable {
289289 AsyncStream { continuation in
290290 let subscription = AggregateSubscription (
291291 function: . min,
@@ -306,13 +306,13 @@ extension CoreDataRepository {
306306 /// Subscribe to the min or minimum of a managed object's numeric property for all instances that satisfy the
307307 /// predicate.
308308 @inlinable
309- public func minThrowingSubscription< Value: Numeric > (
309+ public func minThrowingSubscription< Value> (
310310 predicate: NSPredicate ,
311311 entityDesc: NSEntityDescription ,
312312 attributeDesc: NSAttributeDescription ,
313313 groupBy: NSAttributeDescription ? = nil ,
314314 as _: Value . Type
315- ) -> AsyncThrowingStream < Value , Error > {
315+ ) -> AsyncThrowingStream < Value , Error > where Value : Numeric , Value : Sendable {
316316 AsyncThrowingStream { continuation in
317317 let subscription = AggregateThrowingSubscription (
318318 function: . min,
@@ -334,13 +334,13 @@ extension CoreDataRepository {
334334
335335 /// Get the sum of a managed object's numeric property for all instances that satisfy the predicate.
336336 @inlinable
337- public func sum< Value: Numeric > (
337+ public func sum< Value> (
338338 predicate: NSPredicate ,
339339 entityDesc: NSEntityDescription ,
340340 attributeDesc: NSAttributeDescription ,
341341 groupBy: NSAttributeDescription ? = nil ,
342342 as _: Value . Type
343- ) async -> Result < Value , CoreDataError > {
343+ ) async -> Result < Value , CoreDataError > where Value : Numeric , Value : Sendable {
344344 await Self . send (
345345 function: . sum,
346346 context: context,
@@ -353,13 +353,13 @@ extension CoreDataRepository {
353353
354354 /// Subscribe to the sum of a managed object's numeric property for all instances that satisfy the predicate.
355355 @inlinable
356- public func sumSubscription< Value: Numeric > (
356+ public func sumSubscription< Value> (
357357 predicate: NSPredicate ,
358358 entityDesc: NSEntityDescription ,
359359 attributeDesc: NSAttributeDescription ,
360360 groupBy: NSAttributeDescription ? = nil ,
361361 as _: Value . Type
362- ) -> AsyncStream < Result < Value , CoreDataError > > {
362+ ) -> AsyncStream < Result < Value , CoreDataError > > where Value : Numeric , Value : Sendable {
363363 AsyncStream { continuation in
364364 let subscription = AggregateSubscription (
365365 function: . sum,
@@ -379,13 +379,13 @@ extension CoreDataRepository {
379379
380380 /// Subscribe to the sum of a managed object's numeric property for all instances that satisfy the predicate.
381381 @inlinable
382- public func sumThrowingSubscription< Value: Numeric > (
382+ public func sumThrowingSubscription< Value> (
383383 predicate: NSPredicate ,
384384 entityDesc: NSEntityDescription ,
385385 attributeDesc: NSAttributeDescription ,
386386 groupBy: NSAttributeDescription ? = nil ,
387387 as _: Value . Type
388- ) -> AsyncThrowingStream < Value , Error > {
388+ ) -> AsyncThrowingStream < Value , Error > where Value : Numeric , Value : Sendable {
389389 AsyncThrowingStream { continuation in
390390 let subscription = AggregateThrowingSubscription (
391391 function: . sum,
@@ -405,10 +405,10 @@ extension CoreDataRepository {
405405
406406 // MARK: Internals
407407
408- private static func aggregate< Value: Numeric > (
408+ private static func aggregate< Value> (
409409 context: NSManagedObjectContext ,
410410 request: NSFetchRequest < NSDictionary >
411- ) throws -> Value {
411+ ) throws -> Value where Value : Numeric , Value : Sendable {
412412 let result = try context. fetch ( request)
413413 guard let value: Value = result. asAggregateValue ( ) else {
414414 throw CoreDataError . fetchedObjectFailedToCastToExpectedType
@@ -424,7 +424,7 @@ extension CoreDataRepository {
424424 entityDesc: NSEntityDescription ,
425425 attributeDesc: NSAttributeDescription ,
426426 groupBy: NSAttributeDescription ? = nil
427- ) async -> Result < Value , CoreDataError > where Value: Numeric {
427+ ) async -> Result < Value , CoreDataError > where Value: Numeric , Value : Sendable {
428428 guard entityDesc == attributeDesc. entity else {
429429 return . failure( . propertyDoesNotMatchEntity)
430430 }
0 commit comments