Skip to main content

Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        ctx: Context,
    ) -> Pin<Box<dyn Future<Output = BotResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Core trait for all update handlers.

Implementors receive a Context and return a future that resolves to BotResult<()>. Returning Ok(()) allows subsequent handlers to run; the dispatcher stops the chain on Err.

Required Methods§

Source

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

Processes an incoming update and returns whether the dispatcher should continue.

Implementations on Foreign Types§

Source§

impl Handler for Arc<dyn Handler>

Source§

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

Implementors§

Source§

impl Handler for LoggingHandler

Source§

impl<F, Fut> Handler for HandlerFn<F>
where F: Fn(Context) -> Fut + Send + Sync + 'static, Fut: Future<Output = BotResult<()>> + Send + 'static,