MessageHandler

Trait MessageHandler 

Source
pub trait MessageHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn on_message<'life0, 'async_trait>(
        &'life0 self,
        msg: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_custom_message<'life0, 'async_trait>(
        &'life0 self,
        msg: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_notice_message<'life0, 'async_trait>(
        &'life0 self,
        msg: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 Response,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_ack_message<'life0, 'async_trait>(
        &'life0 self,
        msg: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_data<'life0, 'async_trait>(
        &'life0 self,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn supported_commands(&self) -> Vec<Command> { ... }
    fn supports_command(&self, command: Command) -> bool { ... }
}

Required Methods§

Source

fn on_message<'life0, 'async_trait>( &'life0 self, msg: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理消息

Source

fn on_custom_message<'life0, 'async_trait>( &'life0 self, msg: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理自定义消息

Source

fn on_notice_message<'life0, 'async_trait>( &'life0 self, msg: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理通知消息

Source

fn on_response<'life0, 'life1, 'async_trait>( &'life0 self, msg: &'life1 Response, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

处理响应

Source

fn on_ack_message<'life0, 'async_trait>( &'life0 self, msg: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理服务端的ack

Source

fn on_data<'life0, 'async_trait>( &'life0 self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

处理数据消息

Provided Methods§

Source

fn supported_commands(&self) -> Vec<Command>

获取支持的命令列表

Source

fn supports_command(&self, command: Command) -> bool

检查是否支持某个命令

Implementors§