Skip to content
Snippets Groups Projects

Update Bindings

Merged Dariusz Rybicki requested to merge feature/update-bindings into development
4 files
+ 130
130
Compare changes
  • Side-by-side
  • Inline
Files
4
  • fced4806
    WIP · fced4806
    Dariusz Rybicki authored
    Comment out code that needs to be updated
import Bindings
public struct ClientCreator {
public var create: (URL, Data, Data, String?) throws -> Void
public func callAsFunction(
directoryURL: URL,
ndf: Data,
password: Data,
regCode: String? = nil
) throws {
try create(directoryURL, ndf, password, regCode)
}
}
extension ClientCreator {
public static let live = ClientCreator { directoryURL, ndf, password, regCode in
var error: NSError?
let network = String(data: ndf, encoding: .utf8)!
let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error)
if let error = error {
throw error
}
if !created {
fatalError("BindingsNewClient returned `false` without providing error")
}
}
}
#if DEBUG
extension ClientCreator {
public static let failing = ClientCreator { _, _, _, _ in
struct NotImplemented: Error {}
throw NotImplemented()
}
}
#endif
//import Bindings
//
//public struct ClientCreator {
// public var create: (URL, Data, Data, String?) throws -> Void
//
// public func callAsFunction(
// directoryURL: URL,
// ndf: Data,
// password: Data,
// regCode: String? = nil
// ) throws {
// try create(directoryURL, ndf, password, regCode)
// }
//}
//
//extension ClientCreator {
// public static let live = ClientCreator { directoryURL, ndf, password, regCode in
// var error: NSError?
// let network = String(data: ndf, encoding: .utf8)!
// let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error)
// if let error = error {
// throw error
// }
// if !created {
// fatalError("BindingsNewClient returned `false` without providing error")
// }
// }
//}
//
//#if DEBUG
//extension ClientCreator {
// public static let failing = ClientCreator { _, _, _, _ in
// struct NotImplemented: Error {}
// throw NotImplemented()
// }
//}
//#endif
Loading