diff --git a/Sources/ElixxirDAppsSDK/Connection.swift b/Sources/ElixxirDAppsSDK/Connection.swift index 1d857798b9c82e91f283b67a126e334d2e73baae..4daaacdcce10858290289946a57348cf1cf8816b 100644 --- a/Sources/ElixxirDAppsSDK/Connection.swift +++ b/Sources/ElixxirDAppsSDK/Connection.swift @@ -3,20 +3,23 @@ import Bindings public struct Connection { public var getId: ConnectionGetId public var getPartner: ConnectionGetPartner + public var close: ConnectionClose } extension Connection { public static func live(_ bindingsConnection: BindingsConnection) -> Connection { Connection( getId: .live(bindingsConnection), - getPartner: .live(bindingsConnection) + getPartner: .live(bindingsConnection), + close: .live(bindingsConnection) ) } public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> Connection { Connection( getId: .live(bindingsConnection), - getPartner: .live(bindingsConnection) + getPartner: .live(bindingsConnection), + close: .live(bindingsConnection) ) } } @@ -24,6 +27,7 @@ extension Connection { extension Connection { public static let unimplemented = Connection( getId: .unimplemented, - getPartner: .unimplemented + getPartner: .unimplemented, + close: .unimplemented ) } diff --git a/Sources/ElixxirDAppsSDK/ConnectionClose.swift b/Sources/ElixxirDAppsSDK/ConnectionClose.swift new file mode 100644 index 0000000000000000000000000000000000000000..62115a0a5336eb23d32991e345591cc6da8e69e6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/ConnectionClose.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct ConnectionClose { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension ConnectionClose { + public static func live(_ bindingsConnection: BindingsConnection) -> ConnectionClose { + ConnectionClose(run: bindingsConnection.close) + } + + public static func live(_ bindingsConnection: BindingsAuthenticatedConnection) -> ConnectionClose { + ConnectionClose(run: bindingsConnection.close) + } +} + +extension ConnectionClose { + public static let unimplemented = ConnectionClose( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Legacy/ConnectionCloser.swift b/Sources/ElixxirDAppsSDK/Legacy/ConnectionCloser.swift deleted file mode 100644 index eb31677de4e3c630a944229503e7f3a70289718d..0000000000000000000000000000000000000000 --- a/Sources/ElixxirDAppsSDK/Legacy/ConnectionCloser.swift +++ /dev/null @@ -1,31 +0,0 @@ -import Bindings - -public struct ConnectionCloser { - public var close: () throws -> Void - - public func callAsFunction() throws { - try close() - } -} - -extension ConnectionCloser { - public static func live( - bindingsConnection: BindingsConnection - ) -> ConnectionCloser { - ConnectionCloser(close: bindingsConnection.close) - } - - public static func live( - bindingsAuthenticatedConnection: BindingsAuthenticatedConnection - ) -> ConnectionCloser { - ConnectionCloser(close: bindingsAuthenticatedConnection.close) - } -} - -#if DEBUG -extension ConnectionCloser { - public static let failing = ConnectionCloser { - fatalError("Not implemented") - } -} -#endif