Handler

Trait Handler 

Source
pub trait Handler<C: Codec>: Send + Sync {
    // Required methods
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        request: Message<C>,
        codec: &'life1 C,
    ) -> Pin<Box<dyn Future<Output = Result<Message<C>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn method_name(&self) -> &str;
}

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, request: Message<C>, codec: &'life1 C, ) -> Pin<Box<dyn Future<Output = Result<Message<C>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn method_name(&self) -> &str

Implementors§

Source§

impl<F, Fut, C: Codec + Default> Handler<C> for FnHandler<F, C>
where F: Fn(Message<C>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Message<C>>> + Send + 'static,

Source§

impl<Req, Resp, F, Fut, C> Handler<C> for TypedHandler<Req, Resp, F, C>
where Req: for<'de> Deserialize<'de> + Send + Sync + 'static, Resp: Serialize + Send + Sync + 'static, F: Fn(Req) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Resp>> + Send + 'static, C: Codec + Default,