From 4b4bddbc4ea7741da1c6576dfef0c472e09017e3 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 20 Jul 2022 12:18:37 +0100 Subject: [PATCH] Add StoreReceptionIdentity functor --- .../StoreReceptionIdentity.swift | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Sources/ElixxirDAppsSDK/StoreReceptionIdentity.swift diff --git a/Sources/ElixxirDAppsSDK/StoreReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/StoreReceptionIdentity.swift new file mode 100644 index 00000000..a56f212b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/StoreReceptionIdentity.swift @@ -0,0 +1,31 @@ +import Bindings +import XCTestDynamicOverlay + +public struct StoreReceptionIdentity { + public var run: (String, Data, Int) throws -> Bool + + public func callAsFunction( + key: String, + identity: Data, + cmixId: Int + ) throws -> Bool { + try run(key, identity, cmixId) + } +} + +extension StoreReceptionIdentity { + public static let live = StoreReceptionIdentity { key, identity, cmixId in + var error: NSError? + let result = BindingsStoreReceptionIdentity(key, identity, cmixId, &error) + if let error = error { + throw error + } + return result + } +} + +extension StoreReceptionIdentity { + public static let unimplemented = StoreReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} -- GitLab