Skip to main content

MessageHandler

Type Alias MessageHandler 

Source
pub type MessageHandler = Arc<dyn Fn(Message) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send>> + Send + Sync>;
Expand description

A type-erased, cloneable, async message handler.

Listeners receive one of these from the server and call it for every inbound message. The return value Option<String> is an optional plain-text reply that the listener may format and send back in its wire protocol.

Aliased Type§

pub struct MessageHandler { /* private fields */ }