RequestHandler

Trait RequestHandler 

Source
pub trait RequestHandler:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle<'life0, 'life1, 'async_trait>(
        &'life0 self,
        conn_id: u64,
        request: &'life1 IncomingRequest,
    ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

业务处理器 trait

Required Methods§

Source

fn handle<'life0, 'life1, 'async_trait>( &'life0 self, conn_id: u64, request: &'life1 IncomingRequest, ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

处理请求,返回响应 body(protobuf 编码后的字节) 返回 None 表示不产生响应(例如异步响应场景)

Implementors§

Source§

impl<F, Fut> RequestHandler for FnHandler<F>
where F: Fn(u64, Bytes) -> Fut + Send + Sync + 'static, Fut: Future<Output = Option<Vec<u8>>> + Send + 'static,