Skip to main content

MessageProcessor

Trait MessageProcessor 

Source
pub trait MessageProcessor: Send + Sync {
    // Required method
    fn process<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 MessageContext,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Frame>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn name(&self) -> &str { ... }
}
Expand description

消息处理器

处理具体的业务逻辑

Required Methods§

Source

fn process<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 MessageContext, ) -> Pin<Box<dyn Future<Output = Result<Option<Frame>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

处理消息

§参数
  • ctx: 消息上下文
§返回
  • Ok(Some(Frame)): 需要发送的响应
  • Ok(None): 不需要响应
  • Err: 处理失败

Provided Methods§

Source

fn name(&self) -> &str

处理器名称

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§