diff --git a/Source/Shared/Library/ImageWrapper.swift b/Source/Shared/Library/ImageWrapper.swift index 5877e0b..337ad77 100644 --- a/Source/Shared/Library/ImageWrapper.swift +++ b/Source/Shared/Library/ImageWrapper.swift @@ -15,7 +15,7 @@ public struct ImageWrapper: Codable { self.image = image } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let data = try container.decode(Data.self, forKey: CodingKeys.image) guard let image = Image(data: data) else { @@ -25,7 +25,7 @@ public struct ImageWrapper: Codable { self.image = image } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) guard let data = image.cache_toData() else { throw StorageError.encodingFailed diff --git a/Source/Shared/Library/JSONArrayWrapper.swift b/Source/Shared/Library/JSONArrayWrapper.swift index 71f0418..3f7e622 100644 --- a/Source/Shared/Library/JSONArrayWrapper.swift +++ b/Source/Shared/Library/JSONArrayWrapper.swift @@ -13,7 +13,7 @@ public struct JSONArrayWrapper: Codable { self.jsonArray = jsonArray } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let data = try container.decode(Data.self, forKey: CodingKeys.jsonArray) let object = try JSONSerialization.jsonObject( @@ -28,7 +28,7 @@ public struct JSONArrayWrapper: Codable { self.jsonArray = jsonArray } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) let data = try JSONSerialization.data( withJSONObject: jsonArray, diff --git a/Source/Shared/Library/JSONDictionaryWrapper.swift b/Source/Shared/Library/JSONDictionaryWrapper.swift index 92b1691..c152cc8 100644 --- a/Source/Shared/Library/JSONDictionaryWrapper.swift +++ b/Source/Shared/Library/JSONDictionaryWrapper.swift @@ -13,7 +13,7 @@ public struct JSONDictionaryWrapper: Codable { self.jsonDictionary = jsonDictionary } - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let data = try container.decode(Data.self, forKey: CodingKeys.jsonDictionary) let object = try JSONSerialization.jsonObject( @@ -28,7 +28,7 @@ public struct JSONDictionaryWrapper: Codable { self.jsonDictionary = jsonDictionary } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) let data = try JSONSerialization.data( withJSONObject: jsonDictionary, diff --git a/Source/Shared/Library/Optional+Extension.swift b/Source/Shared/Library/Optional+Extension.swift index 69516b2..b3fef4b 100644 --- a/Source/Shared/Library/Optional+Extension.swift +++ b/Source/Shared/Library/Optional+Extension.swift @@ -1,7 +1,7 @@ import Foundation public extension Optional { - func unwrapOrThrow(error: Error) throws -> Wrapped { + func unwrapOrThrow(error: any Error) throws -> Wrapped { if let value = self { return value } else { diff --git a/Source/Shared/Storage/AsyncStorage.swift b/Source/Shared/Storage/AsyncStorage.swift index 42becd7..26e21fe 100644 --- a/Source/Shared/Storage/AsyncStorage.swift +++ b/Source/Shared/Storage/AsyncStorage.swift @@ -14,7 +14,7 @@ public class AsyncStorage { } extension AsyncStorage { - public func entry(forKey key: Key, completion: @escaping (Result, Error>) -> Void) { + public func entry(forKey key: Key, completion: @escaping (Result, any Error>) -> Void) { serialQueue.async { [weak self] in guard let `self` = self else { completion(.failure(StorageError.deallocated)) @@ -30,7 +30,7 @@ extension AsyncStorage { } } - public func removeObject(forKey key: Key, completion: @escaping (Result<(), Error>) -> Void) { + public func removeObject(forKey key: Key, completion: @escaping (Result<(), any Error>) -> Void) { serialQueue.async { [weak self] in guard let `self` = self else { completion(.failure(StorageError.deallocated)) @@ -50,7 +50,7 @@ extension AsyncStorage { _ object: Value, forKey key: Key, expiry: Expiry? = nil, - completion: @escaping (Result<(), Error>) -> Void) { + completion: @escaping (Result<(), any Error>) -> Void) { serialQueue.async { [weak self] in guard let `self` = self else { completion(.failure(StorageError.deallocated)) @@ -66,7 +66,7 @@ extension AsyncStorage { } } - public func removeAll(completion: @escaping (Result<(), Error>) -> Void) { + public func removeAll(completion: @escaping (Result<(), any Error>) -> Void) { serialQueue.async { [weak self] in guard let `self` = self else { completion(.failure(StorageError.deallocated)) @@ -82,7 +82,7 @@ extension AsyncStorage { } } - public func removeExpiredObjects(completion: @escaping (Result<(), Error>) -> Void) { + public func removeExpiredObjects(completion: @escaping (Result<(), any Error>) -> Void) { serialQueue.async { [weak self] in guard let `self` = self else { completion(.failure(StorageError.deallocated)) @@ -98,7 +98,7 @@ extension AsyncStorage { } } - public func object(forKey key: Key, completion: @escaping (Result) -> Void) { + public func object(forKey key: Key, completion: @escaping (Result) -> Void) { entry(forKey: key, completion: { (result: Result, Error>) in completion(result.map({ entry in return entry.object @@ -109,7 +109,7 @@ extension AsyncStorage { @available(*, deprecated, renamed: "objectExists(forKey:completion:)") public func existsObject( forKey key: Key, - completion: @escaping (Result) -> Void) { + completion: @escaping (Result) -> Void) { object(forKey: key, completion: { (result: Result) in completion(result.map({ _ in return true @@ -119,7 +119,7 @@ extension AsyncStorage { public func objectExists( forKey key: Key, - completion: @escaping (Result) -> Void) { + completion: @escaping (Result) -> Void) { object(forKey: key, completion: { (result: Result) in completion(result.map({ _ in return true