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

Add ContactIdProvider

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