mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +01:00
Rename 'dispatcher' to 'dispatching'
This commit is contained in:
parent
e9f68c67e9
commit
2bd8734482
7 changed files with 31 additions and 31 deletions
|
@ -23,7 +23,7 @@ type Handlers<'a, T, E> =
|
||||||
/// - Handler's fututres are also boxed
|
/// - Handler's fututres are also boxed
|
||||||
/// - [Custom error policy] is also boxed
|
/// - [Custom error policy] is also boxed
|
||||||
/// - All errors from [updater] are ignored (TODO: remove this limitation)
|
/// - All errors from [updater] are ignored (TODO: remove this limitation)
|
||||||
/// - All handlers executed in order (this means that in dispatcher have 2
|
/// - All handlers executed in order (this means that in dispatching have 2
|
||||||
/// upadtes it will first execute some handler into complition with first
|
/// upadtes it will first execute some handler into complition with first
|
||||||
/// update and **then** search for handler for second update, this is probably
|
/// update and **then** search for handler for second update, this is probably
|
||||||
/// wrong)
|
/// wrong)
|
||||||
|
@ -37,7 +37,7 @@ type Handlers<'a, T, E> =
|
||||||
/// async fn run() {
|
/// async fn run() {
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use telebofr::{
|
/// use telebofr::{
|
||||||
/// dispatcher::{
|
/// dispatching::{
|
||||||
/// filter::{error_policy::ErrorPolicy, FilterDispatcher},
|
/// filter::{error_policy::ErrorPolicy, FilterDispatcher},
|
||||||
/// updater::polling,
|
/// updater::polling,
|
||||||
/// },
|
/// },
|
||||||
|
@ -49,7 +49,7 @@ type Handlers<'a, T, E> =
|
||||||
///
|
///
|
||||||
/// let bot = Bot::new("TOKEN");
|
/// let bot = Bot::new("TOKEN");
|
||||||
///
|
///
|
||||||
/// // create dispatcher which handlers can't fail
|
/// // create dispatching which handlers can't fail
|
||||||
/// // with error policy that just ignores all errors (that can't ever happen)
|
/// // with error policy that just ignores all errors (that can't ever happen)
|
||||||
/// let mut dp = FilterDispatcher::<Infallible>::new(ErrorPolicy::Ignore)
|
/// let mut dp = FilterDispatcher::<Infallible>::new(ErrorPolicy::Ignore)
|
||||||
/// // Add 'handler' that will handle all messages sent to the bot
|
/// // Add 'handler' that will handle all messages sent to the bot
|
||||||
|
@ -67,8 +67,8 @@ type Handlers<'a, T, E> =
|
||||||
///
|
///
|
||||||
/// [`std::fmt::Debug`]: std::fmt::Debug
|
/// [`std::fmt::Debug`]: std::fmt::Debug
|
||||||
/// [Custom error policy]:
|
/// [Custom error policy]:
|
||||||
/// crate::dispatcher::filter::error_policy::ErrorPolicy::Custom [updater]:
|
/// crate::dispatching::filter::error_policy::ErrorPolicy::Custom [updater]:
|
||||||
/// crate::dispatcher::updater
|
/// crate::dispatching::updater
|
||||||
pub struct FilterDispatcher<'a, E> {
|
pub struct FilterDispatcher<'a, E> {
|
||||||
message_handlers: Handlers<'a, Message, E>,
|
message_handlers: Handlers<'a, Message, E>,
|
||||||
edited_message_handlers: Handlers<'a, Message, E>,
|
edited_message_handlers: Handlers<'a, Message, E>,
|
|
@ -6,7 +6,7 @@ pub trait Filter<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::Filter;
|
/// use telebofr::dispatching::filter::Filter;
|
||||||
///
|
///
|
||||||
/// let closure = |i: &i32| -> bool { *i >= 42 };
|
/// let closure = |i: &i32| -> bool { *i >= 42 };
|
||||||
/// assert!(closure.test(&42));
|
/// assert!(closure.test(&42));
|
||||||
|
@ -22,7 +22,7 @@ impl<T, F: Fn(&T) -> bool> Filter<T> for F {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::Filter;
|
/// use telebofr::dispatching::filter::Filter;
|
||||||
///
|
///
|
||||||
/// assert!(true.test(&()));
|
/// assert!(true.test(&()));
|
||||||
/// assert_eq!(false.test(&()), false);
|
/// assert_eq!(false.test(&()), false);
|
||||||
|
@ -42,7 +42,7 @@ impl<T> Filter<T> for bool {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{And, Filter};
|
/// use telebofr::dispatching::filter::{And, Filter};
|
||||||
///
|
///
|
||||||
/// // Note: bool can be treated as `Filter` that always return self.
|
/// // Note: bool can be treated as `Filter` that always return self.
|
||||||
/// assert_eq!(And::new(true, false).test(&()), false);
|
/// assert_eq!(And::new(true, false).test(&()), false);
|
||||||
|
@ -73,13 +73,13 @@ where
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{and, Filter};
|
/// use telebofr::dispatching::filter::{and, Filter};
|
||||||
///
|
///
|
||||||
/// assert!(and(true, true).test(&()));
|
/// assert!(and(true, true).test(&()));
|
||||||
/// assert_eq!(and(true, false).test(&()), false);
|
/// assert_eq!(and(true, false).test(&()), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`And::new`]: crate::dispatcher::filter::And::new
|
/// [`And::new`]: crate::dispatching::filter::And::new
|
||||||
pub fn and<A, B>(a: A, b: B) -> And<A, B> {
|
pub fn and<A, B>(a: A, b: B) -> And<A, B> {
|
||||||
And::new(a, b)
|
And::new(a, b)
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ pub fn and<A, B>(a: A, b: B) -> And<A, B> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{Filter, Or};
|
/// use telebofr::dispatching::filter::{Filter, Or};
|
||||||
///
|
///
|
||||||
/// // Note: bool can be treated as `Filter` that always return self.
|
/// // Note: bool can be treated as `Filter` that always return self.
|
||||||
/// assert!(Or::new(true, false).test(&()));
|
/// assert!(Or::new(true, false).test(&()));
|
||||||
|
@ -124,13 +124,13 @@ where
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{or, Filter};
|
/// use telebofr::dispatching::filter::{or, Filter};
|
||||||
///
|
///
|
||||||
/// assert!(or(true, false).test(&()));
|
/// assert!(or(true, false).test(&()));
|
||||||
/// assert_eq!(or(false, false).test(&()), false);
|
/// assert_eq!(or(false, false).test(&()), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Or::new`]: crate::dispatcher::filter::Or::new
|
/// [`Or::new`]: crate::dispatching::filter::Or::new
|
||||||
pub fn or<A, B>(a: A, b: B) -> Or<A, B> {
|
pub fn or<A, B>(a: A, b: B) -> Or<A, B> {
|
||||||
Or::new(a, b)
|
Or::new(a, b)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ pub fn or<A, B>(a: A, b: B) -> Or<A, B> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{Filter, Not};
|
/// use telebofr::dispatching::filter::{Filter, Not};
|
||||||
///
|
///
|
||||||
/// // Note: bool can be treated as `Filter` that always return self.
|
/// // Note: bool can be treated as `Filter` that always return self.
|
||||||
/// assert!(Not::new(false).test(&()));
|
/// assert!(Not::new(false).test(&()));
|
||||||
|
@ -169,13 +169,13 @@ where
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{not, Filter};
|
/// use telebofr::dispatching::filter::{not, Filter};
|
||||||
///
|
///
|
||||||
/// assert!(not(false).test(&()));
|
/// assert!(not(false).test(&()));
|
||||||
/// assert_eq!(not(true).test(&()), false);
|
/// assert_eq!(not(true).test(&()), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Not::new`]: crate::dispatcher::filter::Not::new
|
/// [`Not::new`]: crate::dispatching::filter::Not::new
|
||||||
pub fn not<A>(a: A) -> Not<A> {
|
pub fn not<A>(a: A) -> Not<A> {
|
||||||
Not::new(a)
|
Not::new(a)
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ pub fn not<A>(a: A) -> Not<A> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::{all, dispatcher::filter::Filter};
|
/// use telebofr::{all, dispatching::filter::Filter};
|
||||||
///
|
///
|
||||||
/// assert!(all![true].test(&()));
|
/// assert!(all![true].test(&()));
|
||||||
/// assert!(all![true, true].test(&()));
|
/// assert!(all![true, true].test(&()));
|
||||||
|
@ -199,7 +199,7 @@ pub fn not<A>(a: A) -> Not<A> {
|
||||||
/// assert_eq!(all![false, false].test(&()), false);
|
/// assert_eq!(all![false, false].test(&()), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [filter]: crate::dispatcher::filter::Filter
|
/// [filter]: crate::dispatching::filter::Filter
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! all {
|
macro_rules! all {
|
||||||
($one:expr) => { $one };
|
($one:expr) => { $one };
|
||||||
|
@ -218,7 +218,7 @@ macro_rules! all {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::{any, dispatcher::filter::Filter};
|
/// use telebofr::{any, dispatching::filter::Filter};
|
||||||
///
|
///
|
||||||
/// assert!(any![true].test(&()));
|
/// assert!(any![true].test(&()));
|
||||||
/// assert!(any![true, true].test(&()));
|
/// assert!(any![true, true].test(&()));
|
||||||
|
@ -230,7 +230,7 @@ macro_rules! all {
|
||||||
/// assert_eq!(any![false, false, false].test(&()), false);
|
/// assert_eq!(any![false, false, false].test(&()), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [filter]: crate::dispatcher::filter::Filter
|
/// [filter]: crate::dispatching::filter::Filter
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! any {
|
macro_rules! any {
|
||||||
($one:expr) => { $one };
|
($one:expr) => { $one };
|
||||||
|
@ -246,7 +246,7 @@ macro_rules! any {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{f, And, Filter, Or, F};
|
/// use telebofr::dispatching::filter::{f, And, Filter, Or, F};
|
||||||
///
|
///
|
||||||
/// let flt1 = |i: &i32| -> bool { *i > 17 };
|
/// let flt1 = |i: &i32| -> bool { *i > 17 };
|
||||||
/// let flt2 = |i: &i32| -> bool { *i < 42 };
|
/// let flt2 = |i: &i32| -> bool { *i < 42 };
|
||||||
|
@ -277,7 +277,7 @@ pub struct F<A>(A);
|
||||||
|
|
||||||
/// Constructor fn for [F]
|
/// Constructor fn for [F]
|
||||||
///
|
///
|
||||||
/// [F]: crate::dispatcher::filter::F;
|
/// [F]: crate::dispatching::filter::F;
|
||||||
pub fn f<A>(a: A) -> F<A> {
|
pub fn f<A>(a: A) -> F<A> {
|
||||||
F(a)
|
F(a)
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ pub trait FilterExt<T> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{Filter, FilterExt};
|
/// use telebofr::dispatching::filter::{Filter, FilterExt};
|
||||||
///
|
///
|
||||||
/// let flt = |i: &i32| -> bool { *i > 0 };
|
/// let flt = |i: &i32| -> bool { *i > 0 };
|
||||||
/// let flt = flt.not();
|
/// let flt = flt.not();
|
||||||
|
@ -322,7 +322,7 @@ pub trait FilterExt<T> {
|
||||||
/// assert_eq!(flt.test(&1), false);
|
/// assert_eq!(flt.test(&1), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Not::new`]: crate::dispatcher::filter::Not::new
|
/// [`Not::new`]: crate::dispatching::filter::Not::new
|
||||||
fn not(self) -> Not<Self>
|
fn not(self) -> Not<Self>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
@ -334,7 +334,7 @@ pub trait FilterExt<T> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{Filter, FilterExt};
|
/// use telebofr::dispatching::filter::{Filter, FilterExt};
|
||||||
///
|
///
|
||||||
/// let flt = |i: &i32| -> bool { *i > 0 };
|
/// let flt = |i: &i32| -> bool { *i > 0 };
|
||||||
/// let flt = flt.and(|i: &i32| *i < 42);
|
/// let flt = flt.and(|i: &i32| *i < 42);
|
||||||
|
@ -344,7 +344,7 @@ pub trait FilterExt<T> {
|
||||||
/// assert_eq!(flt.test(&43), false);
|
/// assert_eq!(flt.test(&43), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Not::new`]: crate::dispatcher::filter::And::new
|
/// [`Not::new`]: crate::dispatching::filter::And::new
|
||||||
fn and<B>(self, other: B) -> And<Self, B>
|
fn and<B>(self, other: B) -> And<Self, B>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
@ -356,7 +356,7 @@ pub trait FilterExt<T> {
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use telebofr::dispatcher::filter::{Filter, FilterExt};
|
/// use telebofr::dispatching::filter::{Filter, FilterExt};
|
||||||
///
|
///
|
||||||
/// let flt = |i: &i32| -> bool { *i < 0 };
|
/// let flt = |i: &i32| -> bool { *i < 0 };
|
||||||
/// let flt = flt.or(|i: &i32| *i > 42);
|
/// let flt = flt.or(|i: &i32| *i > 42);
|
||||||
|
@ -366,7 +366,7 @@ pub trait FilterExt<T> {
|
||||||
/// assert_eq!(flt.test(&17), false);
|
/// assert_eq!(flt.test(&17), false);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`Not::new`]: crate::dispatcher::filter::Or::new
|
/// [`Not::new`]: crate::dispatching::filter::Or::new
|
||||||
fn or<B>(self, other: B) -> Or<Self, B>
|
fn or<B>(self, other: B) -> Or<Self, B>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
|
@ -4,9 +4,9 @@ use async_trait::async_trait;
|
||||||
pub use filter::Filter;
|
pub use filter::Filter;
|
||||||
pub use handler::Handler;
|
pub use handler::Handler;
|
||||||
|
|
||||||
pub mod filter;
|
pub mod filters;
|
||||||
pub mod handler;
|
pub mod handler;
|
||||||
pub mod filter;
|
pub mod filters;
|
||||||
pub mod updater;
|
pub mod updater;
|
||||||
|
|
||||||
#[async_trait(? Send)]
|
#[async_trait(? Send)]
|
|
@ -12,6 +12,6 @@ mod errors;
|
||||||
mod network;
|
mod network;
|
||||||
|
|
||||||
mod bot;
|
mod bot;
|
||||||
pub mod dispatcher;
|
pub mod dispatching;
|
||||||
pub mod requests;
|
pub mod requests;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
Loading…
Reference in a new issue