pub trait MessageObserver: Send + Sync {
// Provided methods
fn on_system_command(
&self,
frame: &Frame,
command: &SystemCommand,
command_type: SystemType,
) -> Result<()> { ... }
fn on_message_command(
&self,
frame: &Frame,
command: &PayloadCommand,
command_type: PayloadType,
) -> Result<()> { ... }
fn on_notification_command(
&self,
frame: &Frame,
command: &NotificationCommand,
command_type: NotificationType,
) -> Result<()> { ... }
fn on_custom_command(
&self,
frame: &Frame,
command: &CustomCommand,
) -> Result<()> { ... }
fn on_unknown_command(&self, frame: &Frame) -> Result<()> { ... }
}Expand description
消息观察者 trait
实现此 trait 以处理不同类型的消息事件
Provided Methods§
Sourcefn on_system_command(
&self,
frame: &Frame,
command: &SystemCommand,
command_type: SystemType,
) -> Result<()>
fn on_system_command( &self, frame: &Frame, command: &SystemCommand, command_type: SystemType, ) -> Result<()>
处理系统命令
Sourcefn on_message_command(
&self,
frame: &Frame,
command: &PayloadCommand,
command_type: PayloadType,
) -> Result<()>
fn on_message_command( &self, frame: &Frame, command: &PayloadCommand, command_type: PayloadType, ) -> Result<()>
处理载荷命令
Sourcefn on_notification_command(
&self,
frame: &Frame,
command: &NotificationCommand,
command_type: NotificationType,
) -> Result<()>
fn on_notification_command( &self, frame: &Frame, command: &NotificationCommand, command_type: NotificationType, ) -> Result<()>
处理通知命令
Sourcefn on_custom_command(
&self,
frame: &Frame,
command: &CustomCommand,
) -> Result<()>
fn on_custom_command( &self, frame: &Frame, command: &CustomCommand, ) -> Result<()>
处理自定义命令
Sourcefn on_unknown_command(&self, frame: &Frame) -> Result<()>
fn on_unknown_command(&self, frame: &Frame) -> Result<()>
处理未知命令
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".