mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Rename Dispatcher to FilterDispatcher
Related to https://github.com/telebofr/telebofr/issues/59.
This commit is contained in:
parent
10f3ab71c1
commit
4194e3d283
1 changed files with 9 additions and 9 deletions
|
@ -38,7 +38,7 @@ type Handlers<'a, T, E> =
|
||||||
/// use std::convert::Infallible;
|
/// use std::convert::Infallible;
|
||||||
/// use telebofr::{
|
/// use telebofr::{
|
||||||
/// dispatcher::{
|
/// dispatcher::{
|
||||||
/// simple::{error_policy::ErrorPolicy, Dispatcher},
|
/// simple::{error_policy::ErrorPolicy, FilterDispatcher},
|
||||||
/// updater::polling,
|
/// updater::polling,
|
||||||
/// },
|
/// },
|
||||||
/// };
|
/// };
|
||||||
|
@ -51,7 +51,7 @@ type Handlers<'a, T, E> =
|
||||||
///
|
///
|
||||||
/// // create dispatcher which handlers can't fail
|
/// // create dispatcher 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 = Dispatcher::<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
|
||||||
/// .message_handler(true, |mes: Message| {
|
/// .message_handler(true, |mes: Message| {
|
||||||
/// async move { println!("New message: {:?}", mes) }
|
/// async move { println!("New message: {:?}", mes) }
|
||||||
|
@ -69,7 +69,7 @@ type Handlers<'a, T, E> =
|
||||||
/// [Custom error policy]:
|
/// [Custom error policy]:
|
||||||
/// crate::dispatcher::simple::error_policy::ErrorPolicy::Custom [updater]:
|
/// crate::dispatcher::simple::error_policy::ErrorPolicy::Custom [updater]:
|
||||||
/// crate::dispatcher::updater
|
/// crate::dispatcher::updater
|
||||||
pub struct Dispatcher<'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>,
|
||||||
channel_post_handlers: Handlers<'a, Message, E>,
|
channel_post_handlers: Handlers<'a, Message, E>,
|
||||||
|
@ -80,12 +80,12 @@ pub struct Dispatcher<'a, E> {
|
||||||
error_policy: ErrorPolicy<'a, E>,
|
error_policy: ErrorPolicy<'a, E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, E> Dispatcher<'a, E>
|
impl<'a, E> FilterDispatcher<'a, E>
|
||||||
where
|
where
|
||||||
E: std::fmt::Debug, // TODO: Is this really necessary?
|
E: std::fmt::Debug, // TODO: Is this really necessary?
|
||||||
{
|
{
|
||||||
pub fn new(error_policy: ErrorPolicy<'a, E>) -> Self {
|
pub fn new(error_policy: ErrorPolicy<'a, E>) -> Self {
|
||||||
Dispatcher {
|
FilterDispatcher {
|
||||||
message_handlers: Vec::new(),
|
message_handlers: Vec::new(),
|
||||||
edited_message_handlers: Vec::new(),
|
edited_message_handlers: Vec::new(),
|
||||||
channel_post_handlers: Vec::new(),
|
channel_post_handlers: Vec::new(),
|
||||||
|
@ -293,13 +293,13 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait(? Send)]
|
#[async_trait(? Send)]
|
||||||
impl<'a, U, E> crate::dispatcher::Dispatcher<'a, U> for Dispatcher<'a, E>
|
impl<'a, U, E> crate::dispatcher::Dispatcher<'a, U> for FilterDispatcher<'a, E>
|
||||||
where
|
where
|
||||||
E: std::fmt::Debug,
|
E: std::fmt::Debug,
|
||||||
U: Updater + 'a,
|
U: Updater + 'a,
|
||||||
{
|
{
|
||||||
async fn dispatch(&'a mut self, updater: U) {
|
async fn dispatch(&'a mut self, updater: U) {
|
||||||
Dispatcher::dispatch(self, updater).await
|
FilterDispatcher::dispatch(self, updater).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatcher::{
|
dispatcher::{
|
||||||
simple::{error_policy::ErrorPolicy, Dispatcher},
|
simple::{error_policy::ErrorPolicy, FilterDispatcher},
|
||||||
updater::StreamUpdater,
|
updater::StreamUpdater,
|
||||||
},
|
},
|
||||||
types::{
|
types::{
|
||||||
|
@ -328,7 +328,7 @@ mod tests {
|
||||||
let counter = &AtomicI32::new(0);
|
let counter = &AtomicI32::new(0);
|
||||||
let counter2 = &AtomicI32::new(0);
|
let counter2 = &AtomicI32::new(0);
|
||||||
|
|
||||||
let mut dp = Dispatcher::<Infallible>::new(ErrorPolicy::Ignore)
|
let mut dp = FilterDispatcher::<Infallible>::new(ErrorPolicy::Ignore)
|
||||||
.message_handler(true, |_mes: Message| {
|
.message_handler(true, |_mes: Message| {
|
||||||
async move {
|
async move {
|
||||||
counter.fetch_add(1, Ordering::SeqCst);
|
counter.fetch_add(1, Ordering::SeqCst);
|
||||||
|
|
Loading…
Add table
Reference in a new issue