Skip to content
Snippets Groups Projects

Update Bindings

Merged Dariusz Rybicki requested to merge feature/update-bindings into development
1 file
+ 30
0
Compare changes
  • Side-by-side
  • Inline
import Bindings
import XCTestDynamicOverlay
public struct ContactPubkeyProvider {
public var get: (Data) throws -> Data
public struct GetPublicKeyFromContact {
public var run: (Data) throws -> Data
public func callAsFunction(contact: Data) throws -> Data {
try get(contact)
try run(contact)
}
}
extension ContactPubkeyProvider {
public static let live = ContactPubkeyProvider { contact in
extension GetPublicKeyFromContact {
public static let live = GetPublicKeyFromContact { contact in
var error: NSError?
let pubkey = BindingsGetPubkeyFromContact(contact, &error)
let key = BindingsGetPubkeyFromContact(contact, &error)
if let error = error {
throw error
}
guard let pubkey = pubkey else {
guard let key = key else {
fatalError("BindingsGetPubkeyFromContact returned `nil` without providing error")
}
return pubkey
return key
}
}
#if DEBUG
extension ContactPubkeyProvider {
public static let failing = ContactPubkeyProvider { _ in
struct NotImplemented: Error {}
throw NotImplemented()
}
extension GetPublicKeyFromContact {
public static let unimplemented = GetPublicKeyFromContact(
run: XCTUnimplemented("\(Self.self)")
)
}
#endif
Loading