Skip to content
Snippets Groups Projects

Bindings API wrapper

1 file
+ 6
6
Compare changes
  • Side-by-side
  • Inline
import Bindings
public struct PasswordGenerator {
public var run: () throws -> Data
public var run: (Int) -> Data
public func callAsFunction() throws -> Data {
try run()
public func callAsFunction(numBytes: Int = 32) -> Data {
run(numBytes)
}
}
extension PasswordGenerator {
public static let live = PasswordGenerator {
guard let secret = BindingsGenerateSecret(32) else {
throw BindingsGenerateSecretUnknownError()
public static let live = PasswordGenerator { numBytes in
guard let secret = BindingsGenerateSecret(numBytes) else {
fatalError("BindingsGenerateSecret returned `nil`")
}
return secret
}
@@ -19,9 +19,8 @@ extension PasswordGenerator {
#if DEBUG
extension PasswordGenerator {
public static let failing = PasswordGenerator {
struct NotImplemented: Error {}
throw NotImplemented()
public static let failing = PasswordGenerator { _ in
fatalError("Not implemented")
}
}
#endif
Loading