From a1a2826f97a507fdb0d51b9485c1f8e3665edd44 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 20 Jul 2022 11:42:20 +0100 Subject: [PATCH] Add NewCmix functor --- Sources/ElixxirDAppsSDK/NewCmix.swift | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Sources/ElixxirDAppsSDK/NewCmix.swift diff --git a/Sources/ElixxirDAppsSDK/NewCmix.swift b/Sources/ElixxirDAppsSDK/NewCmix.swift new file mode 100644 index 00000000..193fd57f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/NewCmix.swift @@ -0,0 +1,36 @@ +import Bindings +import XCTestDynamicOverlay + +public struct NewCmix { + public init(run: @escaping (String, String, Data, String?) throws -> Bool) { + self.run = run + } + + public var run: (String, String, Data, String?) throws -> Bool + + public func callAsFunction( + ndfJSON: String, + storageDir: String, + password: Data, + registrationCode: String? + ) throws -> Bool { + try run(ndfJSON, storageDir, password, registrationCode) + } +} + +extension NewCmix { + public static let live = NewCmix { ndfJSON, storageDir, password, registrationCode in + var error: NSError? + let result = BindingsNewCmix(ndfJSON, storageDir, password, registrationCode, &error) + if let error = error { + throw error + } + return result + } +} + +extension NewCmix { + public static let unimplemented = NewCmix( + run: XCTUnimplemented("\(Self.self)") + ) +} -- GitLab