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

Add NDFDownloader

parent 5ac8999d
No related branches found
No related tags found
1 merge request!1Client management
public struct BindingsDownloadAndVerifySignedNdfWithUrlUnknownError: Error, Equatable {
public init() {}
}
import Bindings
public struct NDFDownloader {
public var run: (Environment) throws -> Data
public func callAsFunction(_ env: Environment) throws -> Data {
try run(env)
}
}
extension NDFDownloader {
public static let live = NDFDownloader { env in
var error: NSError?
let data = BindingsDownloadAndVerifySignedNdfWithUrl(
env.url.absoluteString,
env.cert,
&error
)
if let error = error {
throw error
}
guard let data = data else {
throw BindingsDownloadAndVerifySignedNdfWithUrlUnknownError()
}
return data
}
}
#if DEBUG
extension NDFDownloader {
public static let failing = NDFDownloader { _ 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