Skip to main content

Handler

Trait Handler 

Source
pub trait Handler: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn check_update(&self, ctx: &Context) -> bool;
    fn handle_update<'life0, 'async_trait>(
        &'life0 self,
        bot: Bot,
        ctx: Context,
    ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Core trait every handler implements.

Required Methods§

Source

fn name(&self) -> &str

Unique name used for removal from groups.

Source

fn check_update(&self, ctx: &Context) -> bool

Return true if this handler should process the update. Keep it cheap.

Source

fn handle_update<'life0, 'async_trait>( &'life0 self, bot: Bot, ctx: Context, ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the handler. Return Err(ContinueGroups) or Err(EndGroups) to change dispatch flow.

Implementors§