mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-09 11:43:57 +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_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
#dptree = { version = "0.1.0" }
|
dptree = { version = "0.2.0" }
|
||||||
dptree = { git = "https://github.com/WaffleLapkin/dptree", rev = "be04745" }
|
|
||||||
|
|
||||||
tokio = { version = "1.8", features = ["fs"] }
|
tokio = { version = "1.8", features = ["fs"] }
|
||||||
tokio-util = "0.6"
|
tokio-util = "0.6"
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use dptree::{EventKindDescription, HandlerDescription};
|
use dptree::{description::EventKind, HandlerDescription};
|
||||||
use teloxide_core::types::AllowedUpdate;
|
use teloxide_core::types::AllowedUpdate;
|
||||||
|
|
||||||
/// Handler description that is used by [`Dispatcher`].
|
/// Handler description that is used by [`Dispatcher`].
|
||||||
///
|
///
|
||||||
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||||
pub struct DpHandlerDescription {
|
pub struct DpHandlerDescription {
|
||||||
allowed: EventKindDescription<AllowedUpdate>,
|
allowed: EventKind<AllowedUpdate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DpHandlerDescription {
|
impl DpHandlerDescription {
|
||||||
pub(crate) fn of(allowed: AllowedUpdate) -> Self {
|
pub(crate) fn of(allowed: AllowedUpdate) -> Self {
|
||||||
let mut set = HashSet::with_capacity(1);
|
let mut set = HashSet::with_capacity(1);
|
||||||
set.insert(allowed);
|
set.insert(allowed);
|
||||||
Self { allowed: EventKindDescription::InterestList(set) }
|
Self { allowed: EventKind::InterestList(set) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn allowed_updates(&self) -> Vec<AllowedUpdate> {
|
pub(crate) fn allowed_updates(&self) -> Vec<AllowedUpdate> {
|
||||||
use AllowedUpdate::*;
|
use AllowedUpdate::*;
|
||||||
|
|
||||||
match &self.allowed {
|
match &self.allowed {
|
||||||
EventKindDescription::InterestList(set) => set.iter().copied().collect(),
|
EventKind::InterestList(set) => set.iter().copied().collect(),
|
||||||
EventKindDescription::Entry => panic!("No updates were allowed"),
|
EventKind::Entry => panic!("No updates were allowed"),
|
||||||
EventKindDescription::UserDefined => vec![
|
EventKind::UserDefined => vec![
|
||||||
Message,
|
Message,
|
||||||
EditedMessage,
|
EditedMessage,
|
||||||
ChannelPost,
|
ChannelPost,
|
||||||
|
|
Loading…
Reference in a new issue