Struct telers::dispatcher::Dispatcher

source ·
pub struct Dispatcher<Client, Propagator, BackoffType = ExponentialBackoff<SystemClock>> { /* private fields */ }
Expand description

Dispatcher using to dispatch incoming updates to the main router

Implementations§

source§

impl<Client, Propagator, BackoffType> Dispatcher<Client, Propagator, BackoffType>

source

pub fn new<Cfg, PropagatorService, InitError>( main_router: Propagator, bots: impl IntoIterator<Item = Bot<Client>>, polling_timeout: Option<i64>, backoff: BackoffType, allowed_updates: impl IntoIterator<Item = UpdateType>, ) -> Self
where BackoffType: Backoff, Propagator: ToServiceProvider<Config = Cfg, ServiceProvider = PropagatorService, InitError = InitError>, PropagatorService: PropagateEvent<Client>,

Creates new dispatcher

§Arguments
  • main_router - Main router, whose service will propagate updates to the other routers and its observers
  • bots - Bots that will be used for getting updates and sending requests. All bots use the same dispatcher, but each bot has the own polling process. Polling process gets updates and propagates them to the main propagator.
  • polling_timeout - Timeout in seconds for long polling
  • backoff - Backoff used for handling server-side errors and network errors (like connection reset or telegram server is down, etc.) and set timeout between requests to telegram server
  • allowed_updates - List the types of updates you want your bot to receive. For example, specify UpdateType::Message, UpdateType::EditedChannelPost, UpdateType::CallbackQuery to only receive updates of these types.
source§

impl<Client, Propagator> Dispatcher<Client, Propagator>
where Propagator: Default,

source

pub fn builder() -> Builder<Client, Propagator>

source§

impl<Client, Propagator, BackoffType> Dispatcher<Client, Propagator, BackoffType>
where Propagator: Default,

source

pub fn builder_with_backoff( val: BackoffType, ) -> Builder<Client, Propagator, BackoffType>

Trait Implementations§

source§

impl<Client, BackoffType, PropagatorService, Propagator, Cfg, InitError> ToServiceProvider for Dispatcher<Client, Propagator, BackoffType>
where Client: Send + Sync + 'static, Propagator: ToServiceProvider<Config = Cfg, ServiceProvider = PropagatorService, InitError = InitError>,

This converts all dependencies to ServiceProvider and creates Arc<Service> that contains converted ServiceProviders.

§

type Config = Cfg

Service factory configuration
§

type ServiceProvider = Arc<Service<Client, PropagatorService, BackoffType>>

The provider to which the service will be converted
§

type InitError = InitError

Errors potentially raised while building a service
source§

fn to_service_provider( self, config: Self::Config, ) -> Result<Self::ServiceProvider, Self::InitError>

Convert the service factory to the service Read more

Auto Trait Implementations§

§

impl<Client, Propagator, BackoffType> Freeze for Dispatcher<Client, Propagator, BackoffType>
where Propagator: Freeze, BackoffType: Freeze,

§

impl<Client, Propagator, BackoffType> RefUnwindSafe for Dispatcher<Client, Propagator, BackoffType>
where Propagator: RefUnwindSafe, BackoffType: RefUnwindSafe, Client: RefUnwindSafe,

§

impl<Client, Propagator, BackoffType> Send for Dispatcher<Client, Propagator, BackoffType>
where Propagator: Send, BackoffType: Send, Client: Send,

§

impl<Client, Propagator, BackoffType> Sync for Dispatcher<Client, Propagator, BackoffType>
where Propagator: Sync, BackoffType: Sync, Client: Sync,

§

impl<Client, Propagator, BackoffType> Unpin for Dispatcher<Client, Propagator, BackoffType>
where Propagator: Unpin, BackoffType: Unpin,

§

impl<Client, Propagator, BackoffType> UnwindSafe for Dispatcher<Client, Propagator, BackoffType>
where Propagator: UnwindSafe, BackoffType: UnwindSafe, Client: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T