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

Add IdentityMaker

parent 2cbd112d
No related branches found
No related tags found
1 merge request!2Bindings API wrapper
......@@ -3,13 +3,15 @@ import Bindings
public struct Client {
public var networkFollower: NetworkFollower
public var waitForNetwork: NetworkWaiter
public var makeIdentity: IdentityMaker
}
extension Client {
public static func live(bindingsClient: BindingsClient) -> Client {
Client(
networkFollower: .live(bindingsClient: bindingsClient),
waitForNetwork: .live(bindingsClient: bindingsClient)
waitForNetwork: .live(bindingsClient: bindingsClient),
makeIdentity: .live(bindingsClient: bindingsClient)
)
}
}
......@@ -18,7 +20,8 @@ extension Client {
extension Client {
public static let failing = Client(
networkFollower: .failing,
waitForNetwork: .failing
waitForNetwork: .failing,
makeIdentity: .failing
)
}
#endif
import Bindings
public struct IdentityMaker {
public var make: () throws -> Data
public func callAsFunction() throws -> Data {
try make()
}
}
extension IdentityMaker {
public static func live(bindingsClient: BindingsClient) -> IdentityMaker {
IdentityMaker {
try bindingsClient.makeIdentity()
}
}
}
#if DEBUG
extension IdentityMaker {
public static let failing = IdentityMaker {
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