mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Add a flowchart to FilterDispatcher
This commit is contained in:
parent
6d624c59a9
commit
b97dbe0cb5
3 changed files with 14 additions and 13 deletions
BIN
media/FILTER_DP_FLOWCHART.png
Normal file
BIN
media/FILTER_DP_FLOWCHART.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
|
@ -17,19 +17,19 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
|
||||||
|
|
||||||
/// A dispatcher based on filters.
|
/// A dispatcher based on filters.
|
||||||
///
|
///
|
||||||
/// Filters and handlers are executed in order of registering. The pseudocode
|
/// It consists of:
|
||||||
/// looks like this:
|
/// 1. [`ErrorHandler`] than handles errors both from [`Updater`] and
|
||||||
|
/// [`Handler`].
|
||||||
|
/// 2. Filters and handlers.
|
||||||
///
|
///
|
||||||
/// ```no
|
/// First you register filters and handlers using the methods defined below, and
|
||||||
/// for pair in handlers_and_filters {
|
/// then you call [`.dispatch(updater)`]. Filters and handlers are executed in
|
||||||
/// if pair.filter.test(update) {
|
/// order of registering. The following flowchart represents how this dispatcher
|
||||||
/// pair.handle(update);
|
/// acts:
|
||||||
/// return;
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
///
|
///
|
||||||
/// log("unhandeled update: " + update);
|
/// <div align="center">
|
||||||
/// ```
|
/// <img src="https://github.com/teloxide/teloxide/blob/dev/media/FILTER_DP_FLOWCHART.png" width="700" />
|
||||||
|
/// </div>
|
||||||
///
|
///
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
///
|
///
|
||||||
|
@ -70,6 +70,7 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
|
||||||
///
|
///
|
||||||
/// [`std::fmt::Debug`]: std::fmt::Debug
|
/// [`std::fmt::Debug`]: std::fmt::Debug
|
||||||
/// [updater]: crate::dispatching::updater
|
/// [updater]: crate::dispatching::updater
|
||||||
|
/// [`.dispatch(updater)`]: FilterDispatcher::dispatch
|
||||||
pub struct FilterDispatcher<'a, E, Eh> {
|
pub struct FilterDispatcher<'a, E, Eh> {
|
||||||
message_handlers: FiltersWithHandlers<'a, Message, E>,
|
message_handlers: FiltersWithHandlers<'a, Message, E>,
|
||||||
edited_message_handlers: FiltersWithHandlers<'a, Message, E>,
|
edited_message_handlers: FiltersWithHandlers<'a, Message, E>,
|
||||||
|
|
|
@ -115,7 +115,7 @@ impl<S, E> Updater<E> for S where S: Stream<Item = Result<Update, E>> {}
|
||||||
|
|
||||||
/// Returns a long polling updater with the default configuration.
|
/// Returns a long polling updater with the default configuration.
|
||||||
///
|
///
|
||||||
/// [`polling`]: polling
|
/// See also: [`polling`](polling).
|
||||||
pub fn polling_default(bot: &Bot) -> impl Updater<RequestError> + '_ {
|
pub fn polling_default(bot: &Bot) -> impl Updater<RequestError> + '_ {
|
||||||
polling(bot, None, None, None)
|
polling(bot, None, None, None)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ pub fn polling_default(bot: &Bot) -> impl Updater<RequestError> + '_ {
|
||||||
/// - `allowed_updates`: A list the types of updates you want to receive.
|
/// - `allowed_updates`: A list the types of updates you want to receive.
|
||||||
/// See [`GetUpdates`] for defaults.
|
/// See [`GetUpdates`] for defaults.
|
||||||
///
|
///
|
||||||
/// See also: [`polling_default`](polling_default)
|
/// See also: [`polling_default`](polling_default).
|
||||||
///
|
///
|
||||||
/// [`GetUpdates`]: crate::requests::payloads::GetUpdates
|
/// [`GetUpdates`]: crate::requests::payloads::GetUpdates
|
||||||
pub fn polling(
|
pub fn polling(
|
||||||
|
|
Loading…
Reference in a new issue