Update dptree, now to a crates.io version!

This commit is contained in:
Maybe Waffle 2022-04-18 14:13:39 +04:00
parent 63a7b02c68
commit 63b3be8db7
2 changed files with 7 additions and 8 deletions

View file

@ -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"

View file

@ -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,