Skip to main content

MessageHandler

Trait MessageHandler 

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

    // Provided methods
    fn on_sync_buf_updated<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _sync_buf: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn on_start<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

The handler trait users implement to receive messages.

Required Methods§

Source

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

Called for each inbound user message.

Provided Methods§

Source

fn on_sync_buf_updated<'life0, 'life1, 'async_trait>( &'life0 self, _sync_buf: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when get_updates_buf changes — persist it here.

Source

fn on_start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lifecycle hook: called before the poll loop starts.

Source

fn on_shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lifecycle hook: called after the poll loop ends.

Implementors§