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 resolving to BotResult<()>.

The return value does not influence routing. The dispatcher runs only the first route whose filter matches, and an Err is logged rather than propagated or passed to another handler — so returning an error reports a failure, it does not hand control anywhere else.

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.

Dyn Compatibility§

This trait is dyn compatible.

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

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,