From ccfd09c4e45ebbb337be865e4d1ae62547dea95c Mon Sep 17 00:00:00 2001
From: Dariusz Rybicki <dariusz@elixxir.io>
Date: Wed, 14 Sep 2022 21:08:08 +0200
Subject: [PATCH] Add DeserializeGroup function wrapper

---
 .../XXClient/Functions/DeserializeGroup.swift | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Sources/XXClient/Functions/DeserializeGroup.swift

diff --git a/Sources/XXClient/Functions/DeserializeGroup.swift b/Sources/XXClient/Functions/DeserializeGroup.swift
new file mode 100644
index 00000000..f117051a
--- /dev/null
+++ b/Sources/XXClient/Functions/DeserializeGroup.swift
@@ -0,0 +1,32 @@
+import Bindings
+import XCTestDynamicOverlay
+
+public struct DeserializeGroup {
+  public var run: (Data) throws -> Group
+
+  public func callAsFunction(_ serializedGroupData: Data) throws -> Group {
+    try run(serializedGroupData)
+  }
+}
+
+extension DeserializeGroup {
+  public static func live() -> DeserializeGroup {
+    DeserializeGroup { serializedGroupData in
+      var error: NSError?
+      let bindingsGroup = BindingsDeserializeGroup(serializedGroupData, &error)
+      if let error = error {
+        throw error
+      }
+      guard let bindingsGroup = bindingsGroup else {
+        fatalError("BindingsDeserializeGroup returned `nil` without providing error")
+      }
+      return .live(bindingsGroup)
+    }
+  }
+}
+
+extension DeserializeGroup {
+  public static let unimplemented = DeserializeGroup(
+    run: XCTUnimplemented("\(Self.self)")
+  )
+}
-- 
GitLab