Skip to main content

MessageHandler

Trait MessageHandler 

Source
pub trait MessageHandler: Send + Sync {
    // Required method
    fn handle<'a>(
        &'a self,
        msg: &'a Message,
    ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'a>>;
}
Expand description

Handler for incoming messages.

Dyn-compatible: handle returns a boxed future so transport adapters can hold Arc<dyn MessageHandler>.

Required Methods§

Source

fn handle<'a>( &'a self, msg: &'a Message, ) -> Pin<Box<dyn Future<Output = Result<Response, Error>> + Send + 'a>>

Handle an incoming message.

§Errors

Returns Error if the message cannot be handled.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§