Skip to content
Snippets Groups Projects
Commit 2c70afd4 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add GetPublicKeyFromContact functor

parent 6a540463
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment