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

Add LoadCmix functor

parent a109e922
Branches
Tags
2 merge requests!102Release 1.0.0,!18Update Bindings
This commit is part of merge request !18. Comments created here will be created in the context of that merge request.
import Bindings
import XCTestDynamicOverlay
public struct LoadCmix {
public var run: (String, Data, Data) throws -> Cmix
public func callAsFunction(
storageDir: String,
password: Data,
cmixParamsJSON: Data
) throws -> Cmix {
try run(storageDir, password, cmixParamsJSON)
}
}
extension LoadCmix {
public static let live = LoadCmix { storageDir, password, cmixParamsJSON in
var error: NSError?
let bindingsCmix = BindingsLoadCmix(storageDir, password, cmixParamsJSON, &error)
if let error = error {
throw error
}
guard let bindingsCmix = bindingsCmix else {
fatalError("BindingsLoadCmix returned `nil` without providing error")
}
return Cmix.live(bindingsCmix)
}
}
extension LoadCmix {
public static let unimplemented = LoadCmix(
run: XCTUnimplemented("\(Self.self)")
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment