pub struct FnHandler<F>(pub F);Expand description
函数形式的处理器包装
Tuple Fields§
§0: FTrait Implementations§
Source§impl<F, Fut> RequestHandler for FnHandler<F>
impl<F, Fut> RequestHandler for FnHandler<F>
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,
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 表示不产生响应(例如异步响应场景)
Auto Trait Implementations§
impl<F> Freeze for FnHandler<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnHandler<F>where
F: RefUnwindSafe,
impl<F> Send for FnHandler<F>where
F: Send,
impl<F> Sync for FnHandler<F>where
F: Sync,
impl<F> Unpin for FnHandler<F>where
F: Unpin,
impl<F> UnwindSafe for FnHandler<F>where
F: UnwindSafe,
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