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

Add AsyncRequestRestlike functor

parent 1312b4cb
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings
import XCTestDynamicOverlay
public struct AsyncRequestRestlike {
public var run: (Int, Data, RestlikeMessage, Data, RestlikeCallback) throws -> Void
public func callAsFunction(
e2eId: Int,
recipient: Data,
request: RestlikeMessage,
paramsJSON: Data,
callback: RestlikeCallback
) throws {
try run(e2eId, recipient, request, paramsJSON, callback)
}
}
extension AsyncRequestRestlike {
public static let live = AsyncRequestRestlike { e2dId, recipient, request, paramsJSON, callback in
var error: NSError?
let result = BindingsAsyncRequestRestLike(
e2dId,
recipient,
try request.encode(),
paramsJSON,
callback.makeBindingsRestlikeCallback(),
&error
)
if let error = error {
throw error
}
guard result else {
fatalError("BindingsAsyncRequestRestLike returned `false` without providing error")
}
}
}
extension AsyncRequestRestlike {
public static let unimplemented = AsyncRequestRestlike(
run: XCTUnimplemented("\(Self.self)")
)
}
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