telegram_bot2/__private/
mod.rs1use async_trait::async_trait;
2
3#[cfg(feature = "daemons")]
4pub mod daemon;
5
6#[cfg(feature = "commands")]
7pub mod command;
8
9use crate::bot::Bot;
10use crate::models::{Update, UpdateType};
11use crate::state::BotState;
12
13pub struct GenericHandler<T>
14where
15 T: Sync,
16{
17 pub rank: usize,
18 pub name: &'static str,
19 pub handler: Box<dyn Handler<T>>,
20 pub updates: Vec<UpdateType>,
21}
22
23#[async_trait]
26pub trait Handler<T: Sync> {
27 async fn handle(&self, bot: &Bot, update: &Update, state: Option<&BotState<T>>) -> Result<(), HandlerError>;
29}
30
31#[derive(Debug)]
34pub enum HandlerError {
35 Parse,
37 Runtime,
39}