diff --git a/Sources/ElixxirDAppsSDK/Client.swift b/Sources/ElixxirDAppsSDK/Client.swift index 650e6dc0c806e4abef292e405509cb02522dafef..306517dede95292e9cd13c8744bf21dda8c319d7 100644 --- a/Sources/ElixxirDAppsSDK/Client.swift +++ b/Sources/ElixxirDAppsSDK/Client.swift @@ -1,48 +1,48 @@ -import Bindings - -public struct Client { - public var getId: ClientIdProvider - public var hasRunningProcesses: ClientProcessStatusProvider - public var networkFollower: NetworkFollower - public var waitForNetwork: NetworkWaiter - public var isNetworkHealthy: NetworkHealthProvider - public var monitorNetworkHealth: NetworkHealthListener - public var listenErrors: ClientErrorListener - public var makeIdentity: IdentityMaker - public var connect: ConnectionMaker - public var waitForDelivery: MessageDeliveryWaiter -} - -extension Client { - public static func live(bindingsClient: BindingsCmix) -> Client { - Client( - getId: .live(bindingsClient: bindingsClient), - hasRunningProcesses: .live(bindingsClient: bindingsClient), - networkFollower: .live(bindingsClient: bindingsClient), - waitForNetwork: .live(bindingsClient: bindingsClient), - isNetworkHealthy: .live(bindingsClient: bindingsClient), - monitorNetworkHealth: .live(bindingsClient: bindingsClient), - listenErrors: .live(bindingsClient: bindingsClient), - makeIdentity: .live(bindingsClient: bindingsClient), - connect: .live(bindingsClient: bindingsClient), - waitForDelivery: .live(bindingsClient: bindingsClient) - ) - } -} - -#if DEBUG -extension Client { - public static let failing = Client( - getId: .failing, - hasRunningProcesses: .failing, - networkFollower: .failing, - waitForNetwork: .failing, - isNetworkHealthy: .failing, - monitorNetworkHealth: .failing, - listenErrors: .failing, - makeIdentity: .failing, - connect: .failing, - waitForDelivery: .failing - ) -} -#endif +//import Bindings +// +//public struct Client { +// public var getId: ClientIdProvider +// public var hasRunningProcesses: ClientProcessStatusProvider +// public var networkFollower: NetworkFollower +// public var waitForNetwork: NetworkWaiter +// public var isNetworkHealthy: NetworkHealthProvider +// public var monitorNetworkHealth: NetworkHealthListener +// public var listenErrors: ClientErrorListener +// public var makeIdentity: IdentityMaker +// public var connect: ConnectionMaker +// public var waitForDelivery: MessageDeliveryWaiter +//} +// +//extension Client { +// public static func live(bindingsClient: BindingsCmix) -> Client { +// Client( +// getId: .live(bindingsClient: bindingsClient), +// hasRunningProcesses: .live(bindingsClient: bindingsClient), +// networkFollower: .live(bindingsClient: bindingsClient), +// waitForNetwork: .live(bindingsClient: bindingsClient), +// isNetworkHealthy: .live(bindingsClient: bindingsClient), +// monitorNetworkHealth: .live(bindingsClient: bindingsClient), +// listenErrors: .live(bindingsClient: bindingsClient), +// makeIdentity: .live(bindingsClient: bindingsClient), +// connect: .live(bindingsClient: bindingsClient), +// waitForDelivery: .live(bindingsClient: bindingsClient) +// ) +// } +//} +// +//#if DEBUG +//extension Client { +// public static let failing = Client( +// getId: .failing, +// hasRunningProcesses: .failing, +// networkFollower: .failing, +// waitForNetwork: .failing, +// isNetworkHealthy: .failing, +// monitorNetworkHealth: .failing, +// listenErrors: .failing, +// makeIdentity: .failing, +// connect: .failing, +// waitForDelivery: .failing +// ) +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift b/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift index 6af64a4e46f19ae1b6d7f5c13348a99d1cf1672f..4590644a75b3a7ff1d8fdd4d3a7670af957f3a10 100644 --- a/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift +++ b/Sources/ElixxirDAppsSDK/ClientE2ELogin.swift @@ -1,36 +1,36 @@ -import Bindings - -public struct ClientE2ELogin { - public var login: (Client) throws -> ClientE2E - - public func callAsFunction(with client: Client) throws -> ClientE2E { - try login(client) - } -} - -extension ClientE2ELogin { - public static let live = ClientE2ELogin { client in - var error: NSError? - let cMixId = client.getId() - let myIdentity = try client.makeIdentity() - let encoder = JSONEncoder() - let myIdentityData = try encoder.encode(myIdentity) - let bindingsClientE2E = BindingsLoginE2e(cMixId, nil, myIdentityData, &error) - if let error = error { - throw error - } - guard let bindingsClientE2E = bindingsClientE2E else { - fatalError("BindingsLoginE2E returned `nil` without providing error") - } - return ClientE2E.live(bindingsClientE2E: bindingsClientE2E) - } -} - -#if DEBUG -extension ClientE2ELogin { - public static let failing = ClientE2ELogin { _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif +//import Bindings +// +//public struct ClientE2ELogin { +// public var login: (Client) throws -> ClientE2E +// +// public func callAsFunction(with client: Client) throws -> ClientE2E { +// try login(client) +// } +//} +// +//extension ClientE2ELogin { +// public static let live = ClientE2ELogin { client in +// var error: NSError? +// let cMixId = client.getId() +// let myIdentity = try client.makeIdentity() +// let encoder = JSONEncoder() +// let myIdentityData = try encoder.encode(myIdentity) +// let bindingsClientE2E = BindingsLoginE2e(cMixId, nil, myIdentityData, &error) +// if let error = error { +// throw error +// } +// guard let bindingsClientE2E = bindingsClientE2E else { +// fatalError("BindingsLoginE2E returned `nil` without providing error") +// } +// return ClientE2E.live(bindingsClientE2E: bindingsClientE2E) +// } +//} +// +//#if DEBUG +//extension ClientE2ELogin { +// public static let failing = ClientE2ELogin { _ in +// struct NotImplemented: Error {} +// throw NotImplemented() +// } +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/ClientLoader.swift b/Sources/ElixxirDAppsSDK/ClientLoader.swift index 7c1ca48a5972eb644509ac569b167eeb31a64172..b5297287e3ca3e815d0b99a7ea33d82598400700 100644 --- a/Sources/ElixxirDAppsSDK/ClientLoader.swift +++ b/Sources/ElixxirDAppsSDK/ClientLoader.swift @@ -1,32 +1,32 @@ -import Bindings - -public struct ClientLoader { - public var load: (URL, Data) throws -> Client - - public func callAsFunction(directoryURL: URL, password: Data) throws -> Client { - try load(directoryURL, password) - } -} - -extension ClientLoader { - public static let live = ClientLoader { directoryURL, password in - var error: NSError? - let bindingsClient = BindingsLogin(directoryURL.path, password, &error) - if let error = error { - throw error - } - guard let bindingsClient = bindingsClient else { - fatalError("BindingsLogin returned `nil` without providing error") - } - return Client.live(bindingsClient: bindingsClient) - } -} - -#if DEBUG -extension ClientLoader { - public static let failing = ClientLoader { _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif +//import Bindings +// +//public struct ClientLoader { +// public var load: (URL, Data) throws -> Client +// +// public func callAsFunction(directoryURL: URL, password: Data) throws -> Client { +// try load(directoryURL, password) +// } +//} +// +//extension ClientLoader { +// public static let live = ClientLoader { directoryURL, password in +// var error: NSError? +// let bindingsClient = BindingsLogin(directoryURL.path, password, &error) +// if let error = error { +// throw error +// } +// guard let bindingsClient = bindingsClient else { +// fatalError("BindingsLogin returned `nil` without providing error") +// } +// return Client.live(bindingsClient: bindingsClient) +// } +//} +// +//#if DEBUG +//extension ClientLoader { +// public static let failing = ClientLoader { _, _ in +// struct NotImplemented: Error {} +// throw NotImplemented() +// } +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/ClientStorage.swift b/Sources/ElixxirDAppsSDK/ClientStorage.swift index 7c18828b69e30f48fd14c69ec16913d2785bc784..31700520af54e2096993300fc9468becc72d565e 100644 --- a/Sources/ElixxirDAppsSDK/ClientStorage.swift +++ b/Sources/ElixxirDAppsSDK/ClientStorage.swift @@ -1,69 +1,69 @@ -import Bindings - -public struct ClientStorage { - public var hasStoredClient: () -> Bool - public var createClient: () throws -> Client - public var loadClient: () throws -> Client - public var removeClient: () throws -> Void -} - -extension ClientStorage { - public static let defaultDirectoryURL = FileManager.default - .urls(for: .applicationSupportDirectory, in: .userDomainMask) - .first! - .appendingPathComponent("xx.network.client") - - public static func live( - environment: Environment = .mainnet, - directoryURL: URL = defaultDirectoryURL, - fileManager: FileManager = .default, - generatePassword: PasswordGenerator = .live, - passwordStorage: PasswordStorage, - downloadNDF: NDFDownloader = .live, - createClient: ClientCreator = .live, - loadClient: ClientLoader = .live - ) -> ClientStorage { - ClientStorage( - hasStoredClient: { - let contents = try? fileManager.contentsOfDirectory(atPath: directoryURL.path) - return contents.map { $0.isEmpty == false } ?? false - }, - createClient: { - let ndf = try downloadNDF(environment) - let password = generatePassword() - try passwordStorage.save(password) - try? fileManager.removeItem(at: directoryURL) - try? fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true) - try createClient(directoryURL: directoryURL, ndf: ndf, password: password) - return try loadClient(directoryURL: directoryURL, password: password) - }, - loadClient: { - let password = try passwordStorage.load() - return try loadClient(directoryURL: directoryURL, password: password) - }, - removeClient: { - try fileManager.removeItem(at: directoryURL) - } - ) - } -} - -#if DEBUG -extension ClientStorage { - public static let failing = ClientStorage( - hasStoredClient: { false }, - createClient: { - struct NotImplemented: Error {} - throw NotImplemented() - }, - loadClient: { - struct NotImplemented: Error {} - throw NotImplemented() - }, - removeClient: { - struct NotImplemented: Error {} - throw NotImplemented() - } - ) -} -#endif +//import Bindings +// +//public struct ClientStorage { +// public var hasStoredClient: () -> Bool +// public var createClient: () throws -> Client +// public var loadClient: () throws -> Client +// public var removeClient: () throws -> Void +//} +// +//extension ClientStorage { +// public static let defaultDirectoryURL = FileManager.default +// .urls(for: .applicationSupportDirectory, in: .userDomainMask) +// .first! +// .appendingPathComponent("xx.network.client") +// +// public static func live( +// environment: Environment = .mainnet, +// directoryURL: URL = defaultDirectoryURL, +// fileManager: FileManager = .default, +// generatePassword: PasswordGenerator = .live, +// passwordStorage: PasswordStorage, +// downloadNDF: NDFDownloader = .live, +// createClient: ClientCreator = .live, +// loadClient: ClientLoader = .live +// ) -> ClientStorage { +// ClientStorage( +// hasStoredClient: { +// let contents = try? fileManager.contentsOfDirectory(atPath: directoryURL.path) +// return contents.map { $0.isEmpty == false } ?? false +// }, +// createClient: { +// let ndf = try downloadNDF(environment) +// let password = generatePassword() +// try passwordStorage.save(password) +// try? fileManager.removeItem(at: directoryURL) +// try? fileManager.createDirectory(at: directoryURL, withIntermediateDirectories: true) +// try createClient(directoryURL: directoryURL, ndf: ndf, password: password) +// return try loadClient(directoryURL: directoryURL, password: password) +// }, +// loadClient: { +// let password = try passwordStorage.load() +// return try loadClient(directoryURL: directoryURL, password: password) +// }, +// removeClient: { +// try fileManager.removeItem(at: directoryURL) +// } +// ) +// } +//} +// +//#if DEBUG +//extension ClientStorage { +// public static let failing = ClientStorage( +// hasStoredClient: { false }, +// createClient: { +// struct NotImplemented: Error {} +// throw NotImplemented() +// }, +// loadClient: { +// struct NotImplemented: Error {} +// throw NotImplemented() +// }, +// removeClient: { +// struct NotImplemented: Error {} +// throw NotImplemented() +// } +// ) +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift index 00e18a81fef8334f4e329ff2acb5931a7d58d0ce..97f3db747befd7f35e87a8853e2a787103383a2a 100644 --- a/Sources/ElixxirDAppsSDK/Connection.swift +++ b/Sources/ElixxirDAppsSDK/Connection.swift @@ -1,51 +1,51 @@ -import Bindings - -public struct Connection { - public var getId: ConnectionIdProvider - public var isAuthenticated: ConnectionAuthStatusProvider - public var getPartner: ConnectionPartnerProvider - public var send: MessageSender - public var listen: MessageListener - public var close: ConnectionCloser -} - -extension Connection { - public static func live( - bindingsConnection: BindingsConnection - ) -> Connection { - Connection( - getId: .live(bindingsConnection: bindingsConnection), - isAuthenticated: .live(bindingsConnection: bindingsConnection), - getPartner: .live(bindingsConnection: bindingsConnection), - send: .live(bindingsConnection: bindingsConnection), - listen: .live(bindingsConnection: bindingsConnection), - close: .live(bindingsConnection: bindingsConnection) - ) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> Connection { - Connection( - getId: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - isAuthenticated: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - getPartner: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), - close: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection) - ) - } -} - -#if DEBUG -extension Connection { - public static let failing = Connection( - getId: .failing, - isAuthenticated: .failing, - getPartner: .failing, - send: .failing, - listen: .failing, - close: .failing - ) -} -#endif +//import Bindings +// +//public struct Connection { +// public var getId: ConnectionIdProvider +// public var isAuthenticated: ConnectionAuthStatusProvider +// public var getPartner: ConnectionPartnerProvider +// public var send: MessageSender +// public var listen: MessageListener +// public var close: ConnectionCloser +//} +// +//extension Connection { +// public static func live( +// bindingsConnection: BindingsConnection +// ) -> Connection { +// Connection( +// getId: .live(bindingsConnection: bindingsConnection), +// isAuthenticated: .live(bindingsConnection: bindingsConnection), +// getPartner: .live(bindingsConnection: bindingsConnection), +// send: .live(bindingsConnection: bindingsConnection), +// listen: .live(bindingsConnection: bindingsConnection), +// close: .live(bindingsConnection: bindingsConnection) +// ) +// } +// +// public static func live( +// bindingsAuthenticatedConnection: BindingsAuthenticatedConnection +// ) -> Connection { +// Connection( +// getId: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), +// isAuthenticated: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), +// getPartner: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), +// send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), +// listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection), +// close: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection) +// ) +// } +//} +// +//#if DEBUG +//extension Connection { +// public static let failing = Connection( +// getId: .failing, +// isAuthenticated: .failing, +// getPartner: .failing, +// send: .failing, +// listen: .failing, +// close: .failing +// ) +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift index aa3b4d6222166480f64437e5774afcf89cdb57f2..f3ebf0de546d5b345a715bb25150467c4372d7d1 100644 --- a/Sources/ElixxirDAppsSDK/ConnectionMaker.swift +++ b/Sources/ElixxirDAppsSDK/ConnectionMaker.swift @@ -1,44 +1,44 @@ -import Bindings - -public struct ConnectionMaker { - public var connect: (Bool, Data, Int) throws -> Connection - - public func callAsFunction( - withAuthentication: Bool, - recipientContact: Data, - e2eId: Int - ) throws -> Connection { - try connect(withAuthentication, recipientContact, e2eId) - } -} - -extension ConnectionMaker { - public static func live(bindingsClient: BindingsCmix) -> ConnectionMaker { - ConnectionMaker { withAuthentication, recipientContact, e2eId in - if withAuthentication { - return Connection.live( - bindingsAuthenticatedConnection: try bindingsClient.connect( - withAuthentication: e2eId, - recipientContact: recipientContact - ) - ) - } else { - return Connection.live( - bindingsConnection: try bindingsClient.connect( - e2eId, - recipientContact: recipientContact - ) - ) - } - } - } -} - -#if DEBUG -extension ConnectionMaker { - public static let failing = ConnectionMaker { _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif +//import Bindings +// +//public struct ConnectionMaker { +// public var connect: (Bool, Data, Int) throws -> Connection +// +// public func callAsFunction( +// withAuthentication: Bool, +// recipientContact: Data, +// e2eId: Int +// ) throws -> Connection { +// try connect(withAuthentication, recipientContact, e2eId) +// } +//} +// +//extension ConnectionMaker { +// public static func live(bindingsClient: BindingsCmix) -> ConnectionMaker { +// ConnectionMaker { withAuthentication, recipientContact, e2eId in +// if withAuthentication { +// return Connection.live( +// bindingsAuthenticatedConnection: try bindingsClient.connect( +// withAuthentication: e2eId, +// recipientContact: recipientContact +// ) +// ) +// } else { +// return Connection.live( +// bindingsConnection: try bindingsClient.connect( +// e2eId, +// recipientContact: recipientContact +// ) +// ) +// } +// } +// } +//} +// +//#if DEBUG +//extension ConnectionMaker { +// public static let failing = ConnectionMaker { _, _, _ in +// struct NotImplemented: Error {} +// throw NotImplemented() +// } +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/MessageListener.swift b/Sources/ElixxirDAppsSDK/MessageListener.swift index dc2bfd1ce9a7c8b1ec55cf29ee457a0c450398a4..f36171dc1af1c2e1457fa0222a5efa5a72f5739f 100644 --- a/Sources/ElixxirDAppsSDK/MessageListener.swift +++ b/Sources/ElixxirDAppsSDK/MessageListener.swift @@ -1,74 +1,74 @@ -import Bindings - -public struct MessageListener { - public var listen: (Int, String, @escaping (Message) -> Void) -> Void - - public func callAsFunction( - messageType: Int, - listenerName: String = "MessageListener", - callback: @escaping (Message) -> Void - ) { - listen(messageType, listenerName, callback) - } -} - -extension MessageListener { - public static func live( - bindingsConnection: BindingsConnection - ) -> MessageListener { - MessageListener.live( - register: bindingsConnection.registerListener(_:newListener:) - ) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> MessageListener { - MessageListener.live( - register: bindingsAuthenticatedConnection.registerListener(_:newListener:) - ) - } - - private static func live( - register: @escaping (Int, BindingsListenerProtocol) -> Void - ) -> MessageListener { - MessageListener { messageType, listenerName, callback in - register(messageType, Listener(listenerName: listenerName, onHear: callback)) - } - } -} - -private class Listener: NSObject, BindingsListenerProtocol { - init(listenerName: String, onHear: @escaping (Message) -> Void) { - self.listenerName = listenerName - self.onHear = onHear - super.init() - } - - let listenerName: String - let onHear: (Message) -> Void - let decoder = JSONDecoder() - - func hear(_ item: Data?) { - guard let item = item else { - fatalError("BindingsListenerProtocol.hear received `nil`") - } - do { - onHear(try decoder.decode(Message.self, from: item)) - } catch { - fatalError("Message decoding failed with error: \(error)") - } - } - - func name() -> String { - listenerName - } -} - -#if DEBUG -extension MessageListener { - public static let failing = MessageListener { _, _, _ in - fatalError("Not implemented") - } -} -#endif +//import Bindings +// +//public struct MessageListener { +// public var listen: (Int, String, @escaping (Message) -> Void) -> Void +// +// public func callAsFunction( +// messageType: Int, +// listenerName: String = "MessageListener", +// callback: @escaping (Message) -> Void +// ) { +// listen(messageType, listenerName, callback) +// } +//} +// +//extension MessageListener { +// public static func live( +// bindingsConnection: BindingsConnection +// ) -> MessageListener { +// MessageListener.live( +// register: bindingsConnection.registerListener(_:newListener:) +// ) +// } +// +// public static func live( +// bindingsAuthenticatedConnection: BindingsAuthenticatedConnection +// ) -> MessageListener { +// MessageListener.live( +// register: bindingsAuthenticatedConnection.registerListener(_:newListener:) +// ) +// } +// +// private static func live( +// register: @escaping (Int, BindingsListenerProtocol) -> Void +// ) -> MessageListener { +// MessageListener { messageType, listenerName, callback in +// register(messageType, Listener(listenerName: listenerName, onHear: callback)) +// } +// } +//} +// +//private class Listener: NSObject, BindingsListenerProtocol { +// init(listenerName: String, onHear: @escaping (Message) -> Void) { +// self.listenerName = listenerName +// self.onHear = onHear +// super.init() +// } +// +// let listenerName: String +// let onHear: (Message) -> Void +// let decoder = JSONDecoder() +// +// func hear(_ item: Data?) { +// guard let item = item else { +// fatalError("BindingsListenerProtocol.hear received `nil`") +// } +// do { +// onHear(try decoder.decode(Message.self, from: item)) +// } catch { +// fatalError("Message decoding failed with error: \(error)") +// } +// } +// +// func name() -> String { +// listenerName +// } +//} +// +//#if DEBUG +//extension MessageListener { +// public static let failing = MessageListener { _, _, _ in +// fatalError("Not implemented") +// } +//} +//#endif diff --git a/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift b/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift index efe42bc5210035e22e0157e5aec4307d811981a2..435fa8f759cec9e1cebd55ba70b6c4350a1e0ca5 100644 --- a/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift +++ b/Sources/ElixxirDAppsSDK/RestlikeRequestSender.swift @@ -1,48 +1,48 @@ -import Bindings - -public struct RestlikeRequestSender { - public var send: (Int, Int, RestlikeMessage) throws -> RestlikeMessage - - public func callAsFunction( - clientId: Int, - connectionId: Int, - request: RestlikeMessage - ) throws -> RestlikeMessage { - try send(clientId, connectionId, request) - } -} - -extension RestlikeRequestSender { - public static func live(authenticated: Bool) -> RestlikeRequestSender { - RestlikeRequestSender { clientId, connectionId, request in - let encoder = JSONEncoder() - let requestData = try encoder.encode(request) - var error: NSError? - let responseData: Data? - if authenticated { - responseData = BindingsRestlikeRequestAuth(clientId, connectionId, requestData, &error) - } else { - responseData = BindingsRestlikeRequest(clientId, connectionId, requestData, &error) - } - if let error = error { - throw error - } - guard let responseData = responseData else { - let functionName = "BindingsRestlikeRequest\(authenticated ? "Auth" : "")" - fatalError("\(functionName) returned `nil` without providing error") - } - let decoder = JSONDecoder() - let response = try decoder.decode(RestlikeMessage.self, from: responseData) - return response - } - } -} - -#if DEBUG -extension RestlikeRequestSender { - public static let failing = RestlikeRequestSender { _, _, _ in - struct NotImplemented: Error {} - throw NotImplemented() - } -} -#endif +//import Bindings +// +//public struct RestlikeRequestSender { +// public var send: (Int, Int, RestlikeMessage) throws -> RestlikeMessage +// +// public func callAsFunction( +// clientId: Int, +// connectionId: Int, +// request: RestlikeMessage +// ) throws -> RestlikeMessage { +// try send(clientId, connectionId, request) +// } +//} +// +//extension RestlikeRequestSender { +// public static func live(authenticated: Bool) -> RestlikeRequestSender { +// RestlikeRequestSender { clientId, connectionId, request in +// let encoder = JSONEncoder() +// let requestData = try encoder.encode(request) +// var error: NSError? +// let responseData: Data? +// if authenticated { +// responseData = BindingsRestlikeRequestAuth(clientId, connectionId, requestData, &error) +// } else { +// responseData = BindingsRestlikeRequest(clientId, connectionId, requestData, &error) +// } +// if let error = error { +// throw error +// } +// guard let responseData = responseData else { +// let functionName = "BindingsRestlikeRequest\(authenticated ? "Auth" : "")" +// fatalError("\(functionName) returned `nil` without providing error") +// } +// let decoder = JSONDecoder() +// let response = try decoder.decode(RestlikeMessage.self, from: responseData) +// return response +// } +// } +//} +// +//#if DEBUG +//extension RestlikeRequestSender { +// public static let failing = RestlikeRequestSender { _, _, _ in +// struct NotImplemented: Error {} +// throw NotImplemented() +// } +//} +//#endif