Add a flowchart to FilterDispatcher

This commit is contained in:
Temirkhan Myrzamadi 2019-12-31 15:36:45 +06:00
parent 6d624c59a9
commit b97dbe0cb5
3 changed files with 14 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -17,19 +17,19 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
/// A dispatcher based on filters.
///
/// Filters and handlers are executed in order of registering. The pseudocode
/// looks like this:
/// It consists of:
/// 1. [`ErrorHandler`] than handles errors both from [`Updater`] and
/// [`Handler`].
/// 2. Filters and handlers.
///
/// ```no
/// for pair in handlers_and_filters {
/// if pair.filter.test(update) {
/// pair.handle(update);
/// return;
/// }
/// }
/// First you register filters and handlers using the methods defined below, and
/// then you call [`.dispatch(updater)`]. Filters and handlers are executed in
/// order of registering. The following flowchart represents how this dispatcher
/// acts:
///
/// 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
///
@ -70,6 +70,7 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
///
/// [`std::fmt::Debug`]: std::fmt::Debug
/// [updater]: crate::dispatching::updater
/// [`.dispatch(updater)`]: FilterDispatcher::dispatch
pub struct FilterDispatcher<'a, E, Eh> {
message_handlers: FiltersWithHandlers<'a, Message, E>,
edited_message_handlers: FiltersWithHandlers<'a, Message, E>,

View file

@ -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.
///
/// [`polling`]: polling
/// See also: [`polling`](polling).
pub fn polling_default(bot: &Bot) -> impl Updater<RequestError> + '_ {
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.
/// See [`GetUpdates`] for defaults.
///
/// See also: [`polling_default`](polling_default)
/// See also: [`polling_default`](polling_default).
///
/// [`GetUpdates`]: crate::requests::payloads::GetUpdates
pub fn polling(