Skip to main content

handler_fn

Function handler_fn 

Source
pub fn handler_fn<F, Fut>(f: F) -> BoxHandler
where F: Fn(Context) -> Fut + Send + Sync + 'static, Fut: Future<Output = BotResult<()>> + Send + 'static,
Expand description

Creates a BoxHandler from any async function or closure.

§Example

use rustigram_bot::{handler_fn, Context, BotResult};

let h = handler_fn(|ctx: Context| async move {
    if let Some(r) = ctx.reply("pong") { r.await?; }
    Ok(())
});