pub struct ResponseCompletable { /* private fields */ }
Expand description
A completable for a JSON-RPC request. This is an object that must be “completed”, that is, a result must be provided. (this is the inverse of a future)
Must be completed once and only once, otherwise a panic is generated upon drop.
On completion, the on_response callback is invoked. Typically: this will write an appropriate JSON-RPC response to the endpoint output.
Implementations§
Source§impl ResponseCompletable
impl ResponseCompletable
pub fn new( id: Option<Id>, on_response: Box<dyn FnMut(Option<Response>) + Send>, ) -> ResponseCompletable
pub fn complete(self, response_result: Option<ResponseResult>)
pub fn complete_with_error(self, error: RequestError)
pub fn handle_request_with<PARAMS, RET, RET_ERROR, METHOD>(
self,
params: RequestParams,
method_handler: METHOD,
)where
PARAMS: Deserialize,
RET: Serialize,
RET_ERROR: Serialize,
METHOD: FnOnce(PARAMS, MethodCompletable<RET, RET_ERROR>),
pub fn sync_handle_request<PARAMS, RET, RET_ERROR, METHOD>(
self,
params: RequestParams,
sync_method_handler: METHOD,
)where
PARAMS: Deserialize,
RET: Serialize,
RET_ERROR: Serialize,
METHOD: FnOnce(PARAMS) -> MethodResult<RET, RET_ERROR>,
pub fn handle_notification_with<PARAMS, METHOD>(
self,
params: RequestParams,
method_handler: METHOD,
)where
PARAMS: Deserialize,
METHOD: FnOnce(PARAMS),
pub fn sync_handle_notification<PARAMS, METHOD>(
self,
params: RequestParams,
sync_method_handler: METHOD,
)where
PARAMS: Deserialize,
METHOD: FnOnce(PARAMS),
Auto Trait Implementations§
impl Freeze for ResponseCompletable
impl !RefUnwindSafe for ResponseCompletable
impl Send for ResponseCompletable
impl !Sync for ResponseCompletable
impl Unpin for ResponseCompletable
impl !UnwindSafe for ResponseCompletable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more