mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Update dptree, now to a crates.io version!
This commit is contained in:
parent
63a7b02c68
commit
63b3be8db7
2 changed files with 7 additions and 8 deletions
|
@ -62,8 +62,7 @@ teloxide-macros = { git = "https://github.com/teloxide/teloxide-macros.git", rev
|
|||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
#dptree = { version = "0.1.0" }
|
||||
dptree = { git = "https://github.com/WaffleLapkin/dptree", rev = "be04745" }
|
||||
dptree = { version = "0.2.0" }
|
||||
|
||||
tokio = { version = "1.8", features = ["fs"] }
|
||||
tokio-util = "0.6"
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use dptree::{EventKindDescription, HandlerDescription};
|
||||
use dptree::{description::EventKind, HandlerDescription};
|
||||
use teloxide_core::types::AllowedUpdate;
|
||||
|
||||
/// Handler description that is used by [`Dispatcher`].
|
||||
///
|
||||
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||
pub struct DpHandlerDescription {
|
||||
allowed: EventKindDescription<AllowedUpdate>,
|
||||
allowed: EventKind<AllowedUpdate>,
|
||||
}
|
||||
|
||||
impl DpHandlerDescription {
|
||||
pub(crate) fn of(allowed: AllowedUpdate) -> Self {
|
||||
let mut set = HashSet::with_capacity(1);
|
||||
set.insert(allowed);
|
||||
Self { allowed: EventKindDescription::InterestList(set) }
|
||||
Self { allowed: EventKind::InterestList(set) }
|
||||
}
|
||||
|
||||
pub(crate) fn allowed_updates(&self) -> Vec<AllowedUpdate> {
|
||||
use AllowedUpdate::*;
|
||||
|
||||
match &self.allowed {
|
||||
EventKindDescription::InterestList(set) => set.iter().copied().collect(),
|
||||
EventKindDescription::Entry => panic!("No updates were allowed"),
|
||||
EventKindDescription::UserDefined => vec![
|
||||
EventKind::InterestList(set) => set.iter().copied().collect(),
|
||||
EventKind::Entry => panic!("No updates were allowed"),
|
||||
EventKind::UserDefined => vec![
|
||||
Message,
|
||||
EditedMessage,
|
||||
ChannelPost,
|
||||
|
|
Loading…
Reference in a new issue