diff --git a/Sources/RequestDL/Internals/Sources/Cache/Cache Control/Internal.CacheControl.swift b/Sources/RequestDL/Internals/Sources/Cache/Cache Control/Internal.CacheControl.swift index 4df4ad6d..19232254 100644 --- a/Sources/RequestDL/Internals/Sources/Cache/Cache Control/Internal.CacheControl.swift +++ b/Sources/RequestDL/Internals/Sources/Cache/Cache Control/Internal.CacheControl.swift @@ -13,7 +13,7 @@ extension Internals { enum Output { case task(SessionTask) - case cache(((Internals.ResponseHead) -> Internals.AsyncStream?)?) + case cache((@Sendable (Internals.ResponseHead) -> Internals.AsyncStream?)?) } // MARK: - Internal properties @@ -258,7 +258,7 @@ extension Internals { private func cacheIfNeeded( dataCache: DataCache, request: Internals.Request - ) async throws -> ((Internals.ResponseHead) -> Internals.AsyncStream?)? { + ) async throws -> (@Sendable (Internals.ResponseHead) -> Internals.AsyncStream?)? { guard request.isCacheEnabled else { return nil } diff --git a/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map Error/Modifiers.FlatMapError.swift b/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map Error/Modifiers.FlatMapError.swift index 2640dfac..eb5443ce 100644 --- a/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map Error/Modifiers.FlatMapError.swift +++ b/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map Error/Modifiers.FlatMapError.swift @@ -19,7 +19,7 @@ extension Modifiers { // MARK: - Internal properties - let transform: @Sendable (Error) throws -> Void + let transform: @Sendable (Error) async throws -> Void // MARK: - Public methods @@ -34,7 +34,7 @@ extension Modifiers { do { return try await task.result() } catch { - try transform(error) + try await transform(error) throw error } } @@ -65,7 +65,7 @@ extension RequestTask { `transform` closure. */ public func flatMapError( - _ transform: @escaping @Sendable (Error) throws -> Void + _ transform: @escaping @Sendable (Error) async throws -> Void ) -> ModifiedRequestTask> { modifier(Modifiers.FlatMapError(transform: transform)) } @@ -94,11 +94,11 @@ extension RequestTask { */ public func flatMapError( _ type: Failure.Type, - _ transform: @escaping @Sendable (Failure) throws -> Void + _ transform: @escaping @Sendable (Failure) async throws -> Void ) -> ModifiedRequestTask> { flatMapError { if let error = $0 as? Failure { - try transform(error) + try await transform(error) } } } diff --git a/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map/Modifiers.FlatMap.swift b/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map/Modifiers.FlatMap.swift index bbe8768d..db5cc18f 100644 --- a/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map/Modifiers.FlatMap.swift +++ b/Sources/RequestDL/Tasks/Sources/Modifiers/Flat Map/Modifiers.FlatMap.swift @@ -28,7 +28,7 @@ extension Modifiers { // MARK: - Internal properties - let transform: @Sendable (Result) throws -> Output + let transform: @Sendable (Result) async throws -> Output // MARK: - Public methods @@ -48,7 +48,7 @@ extension Modifiers { case .processed(let mapped): return mapped case .original(let original): - return try transform(.success(original)) + return try await transform(.success(original)) } } } @@ -59,13 +59,13 @@ extension Modifiers { do { return .success(.original(try await task.result())) } catch { - return mapErrorIntoResult(error) + return await mapErrorIntoResult(error) } } - private func mapErrorIntoResult(_ error: Error) -> Result { + private func mapErrorIntoResult(_ error: Error) async -> Result { do { - return .success(.processed(try transform(.failure(error)))) + return try await .success(.processed(transform(.failure(error)))) } catch { return .failure(error) } @@ -85,7 +85,7 @@ extension RequestTask { - Returns: A new `RequestTask` that returns the flat-mapped element of type `NewElement`. */ public func flatMap( - _ transform: @escaping @Sendable (Result) throws -> NewElement + _ transform: @escaping @Sendable (Result) async throws -> NewElement ) -> ModifiedRequestTask> { modifier(Modifiers.FlatMap(transform: transform)) } diff --git a/Sources/RequestDL/Tasks/Sources/Modifiers/Map Error/Modifiers.MapError.swift b/Sources/RequestDL/Tasks/Sources/Modifiers/Map Error/Modifiers.MapError.swift index 8fae40a0..66117b88 100644 --- a/Sources/RequestDL/Tasks/Sources/Modifiers/Map Error/Modifiers.MapError.swift +++ b/Sources/RequestDL/Tasks/Sources/Modifiers/Map Error/Modifiers.MapError.swift @@ -12,7 +12,7 @@ extension Modifiers { // MARK: - Internal properties - let transform: @Sendable (Error) throws -> Input + let transform: @Sendable (Error) async throws -> Input // MARK: - Public methods @@ -26,7 +26,7 @@ extension Modifiers { do { return try await task.result() } catch { - return try transform(error) + return try await transform(error) } } } @@ -43,7 +43,7 @@ extension RequestTask { - Returns: The modified task with the ``Modifiers/MapError`` modifier applied. */ public func mapError( - _ transform: @escaping @Sendable (Error) throws -> Element + _ transform: @escaping @Sendable (Error) async throws -> Element ) -> ModifiedRequestTask> { modifier(Modifiers.MapError(transform: transform)) } diff --git a/Sources/RequestDL/Tasks/Sources/Modifiers/Map/Modifiers.Map.swift b/Sources/RequestDL/Tasks/Sources/Modifiers/Map/Modifiers.Map.swift index d12eb072..62ca1094 100644 --- a/Sources/RequestDL/Tasks/Sources/Modifiers/Map/Modifiers.Map.swift +++ b/Sources/RequestDL/Tasks/Sources/Modifiers/Map/Modifiers.Map.swift @@ -29,7 +29,7 @@ extension Modifiers { // MARK: - Internal properties - let transform: @Sendable (Input) throws -> Output + let transform: @Sendable (Input) async throws -> Output // MARK: - Public methods @@ -41,7 +41,7 @@ extension Modifiers { - Throws: The error thrown by the closure, if any. */ public func body(_ task: Content) async throws -> Output { - try transform(await task.result()) + try await transform(task.result()) } } } @@ -57,7 +57,7 @@ extension RequestTask { - Returns: A modified `RequestTask` with the transformed element. */ public func map( - _ transform: @escaping @Sendable (Element) throws -> NewElement + _ transform: @escaping @Sendable (Element) async throws -> NewElement ) -> ModifiedRequestTask> { modifier(Modifiers.Map(transform: transform)) } diff --git a/Sources/RequestDL/Tasks/Sources/Modifiers/On Status Code/Modifiers.OnStatusCode.swift b/Sources/RequestDL/Tasks/Sources/Modifiers/On Status Code/Modifiers.OnStatusCode.swift index 9f800267..2acd050b 100644 --- a/Sources/RequestDL/Tasks/Sources/Modifiers/On Status Code/Modifiers.OnStatusCode.swift +++ b/Sources/RequestDL/Tasks/Sources/Modifiers/On Status Code/Modifiers.OnStatusCode.swift @@ -22,7 +22,7 @@ extension Modifiers { // MARK: - Internal properties let contains: @Sendable (StatusCode) -> Bool - let transform: @Sendable (Input) throws -> Void + let transform: @Sendable (Input) async throws -> Void // MARK: - Public methods @@ -39,7 +39,7 @@ extension Modifiers { return result } - try transform(result) + try await transform(result) return result } } @@ -50,7 +50,7 @@ extension Modifiers { extension RequestTask where Element: TaskResultPrimitive { private func onStatusCode( - _ transform: @escaping @Sendable (Element) throws -> Void, + _ transform: @escaping @Sendable (Element) async throws -> Void, contains: @escaping @Sendable (StatusCode) -> Bool ) -> ModifiedRequestTask> { modifier(Modifiers.OnStatusCode( @@ -72,7 +72,7 @@ extension RequestTask where Element: TaskResultPrimitive { */ public func onStatusCode( _ statusCode: Range, - _ transform: @escaping @Sendable (Element) throws -> Void + _ transform: @escaping @Sendable (Element) async throws -> Void ) -> ModifiedRequestTask> { onStatusCode(transform) { statusCode.contains($0) @@ -92,7 +92,7 @@ extension RequestTask where Element: TaskResultPrimitive { */ public func onStatusCode( _ statusCode: StatusCodeSet, - _ transform: @escaping @Sendable (Element) throws -> Void + _ transform: @escaping @Sendable (Element) async throws -> Void ) -> ModifiedRequestTask> { onStatusCode(transform) { statusCode.contains($0) @@ -112,7 +112,7 @@ extension RequestTask where Element: TaskResultPrimitive { */ public func onStatusCode( _ statusCode: StatusCode, - _ transform: @escaping @Sendable (Element) throws -> Void + _ transform: @escaping @Sendable (Element) async throws -> Void ) -> ModifiedRequestTask> { onStatusCode(transform) { statusCode == $0