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

Add ContactPubkeyProvider

parent d7071f1c
No related branches found
No related tags found
1 merge request!2Bindings API wrapper
import Bindings
public struct ContactPubkeyProvider {
public var get: (Data) throws -> Data
public func callAsFunction(contact: Data) throws -> Data {
try get(contact)
}
}
extension ContactPubkeyProvider {
public static let live = ContactPubkeyProvider { contact in
var error: NSError?
let pubkey = BindingsGetPubkeyFromContact(contact, &error)
if let error = error {
throw error
}
guard let pubkey = pubkey else {
fatalError("BindingsGetPubkeyFromContact returned `nil` without providing error")
}
return pubkey
}
}
#if DEBUG
extension ContactPubkeyProvider {
public static let failing = ContactPubkeyProvider { _ in
struct NotImplemented: Error {}
throw NotImplemented()
}
}
#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