Struct
Responder
pub struct Responder<T> { /* private fields */ }The answer to one async request.
Resolving it takes it; a request is answered once. A responder dropped
without resolve rejects its promise. Every pending
request settles.
Methods
#pub fn new(callback: Box<dyn FnOnce(Result<T, IpcError>) + Send>) -> Self
Creates a responder that hands its result to callback. The runtime
gives one to an async handler; a test of the handler can do the same.
#pub fn is_cancelled(&self) -> bool
Whether this responder has been cancelled. Typically by an incoming RPC_CANCEL from the renderer.
#pub fn resolve(self, result: Result<T, IpcError>)
Answers the request, unless it was cancelled meanwhile.
#pub fn map<U, F>(self, f: F) -> Responder<U>
where
U: 'static,
F: FnOnce(U) -> Result<T, IpcError> + Send + 'static,
Transform the resolved value type.
The returned responder chains through f before calling the original
callback. Useful for wrapping a typed Responder<Res> into a
Responder<Vec<u8>> at the serialisation boundary.
The mapped responder shares the cancellation flag with the source. Cancelling the source or the mapped responder cancels both.