mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
Fmt
This commit is contained in:
parent
510e5d8630
commit
c0f83a4999
2 changed files with 18 additions and 7 deletions
|
@ -3,10 +3,12 @@ use super::{
|
|||
storage::{InMemStorage, Storage},
|
||||
};
|
||||
use crate::{
|
||||
dispatching::{chat::ChatUpdate, Handler, SessionState},
|
||||
dispatching::{
|
||||
chat::{ChatUpdate, ChatUpdateKind},
|
||||
Handler, SessionState,
|
||||
},
|
||||
types::{Update, UpdateKind},
|
||||
};
|
||||
use crate::dispatching::chat::ChatUpdateKind;
|
||||
|
||||
/// A dispatcher that dispatches updates from chats.
|
||||
pub struct Dispatcher<'a, Session, H> {
|
||||
|
@ -53,9 +55,18 @@ where
|
|||
/// crate::dispatching::DispatchResult::Unhandled
|
||||
pub async fn dispatch(&mut self, update: Update) -> DispatchResult {
|
||||
let chat_update = match update.kind {
|
||||
UpdateKind::Message(msg) => ChatUpdate { id: update.id, kind: ChatUpdateKind::Message(msg) },
|
||||
UpdateKind::EditedMessage(msg) => ChatUpdate { id: update.id, kind: ChatUpdateKind::EditedMessage(msg) },
|
||||
UpdateKind::CallbackQuery(query) => ChatUpdate { id: update.id, kind: ChatUpdateKind::CallbackQuery(query) },
|
||||
UpdateKind::Message(msg) => ChatUpdate {
|
||||
id: update.id,
|
||||
kind: ChatUpdateKind::Message(msg),
|
||||
},
|
||||
UpdateKind::EditedMessage(msg) => ChatUpdate {
|
||||
id: update.id,
|
||||
kind: ChatUpdateKind::EditedMessage(msg),
|
||||
},
|
||||
UpdateKind::CallbackQuery(query) => ChatUpdate {
|
||||
id: update.id,
|
||||
kind: ChatUpdateKind::CallbackQuery(query),
|
||||
},
|
||||
_ => return DispatchResult::Unhandled,
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pub trait Handler<Session, U> {
|
|||
) -> Pin<Box<dyn Future<Output = SessionState<Session>> + 'a>>
|
||||
where
|
||||
Session: 'a,
|
||||
U: 'a;
|
||||
U: 'a;
|
||||
}
|
||||
|
||||
/// The implementation of `Handler` for `Fn(Session, Update) -> Future<Output =
|
||||
|
@ -42,7 +42,7 @@ where
|
|||
) -> Pin<Box<dyn Future<Output = Fut::Output> + 'a>>
|
||||
where
|
||||
Session: 'a,
|
||||
U: 'a,
|
||||
U: 'a,
|
||||
{
|
||||
Box::pin(async move { self(session, update).await })
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue