pub trait Handler {
type Notification: DeserializeOwned;
type Request: DeserializeOwned;
// Required methods
fn handle_notification(&mut self, ctx: &RpcCtx, rpc: Self::Notification);
fn handle_request(
&mut self,
ctx: &RpcCtx,
rpc: Self::Request,
) -> Result<Value, RemoteError>;
// Provided method
fn idle(&mut self, ctx: &RpcCtx, token: usize) { ... }
}
Expand description
A trait for types which can handle RPCs.
Types which implement MethodHandler
are also responsible for implementing
Parser
; Parser
is provided when Self::Notification and Self::Request
can be used with serde::DeserializeOwned.