Trait Handler

Source
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.

Required Associated Types§

Required Methods§

Source

fn handle_notification(&mut self, ctx: &RpcCtx, rpc: Self::Notification)

Source

fn handle_request( &mut self, ctx: &RpcCtx, rpc: Self::Request, ) -> Result<Value, RemoteError>

Provided Methods§

Source

fn idle(&mut self, ctx: &RpcCtx, token: usize)

Implementors§