Trait teloxide::dispatching::update_listeners::UpdateListener
source · [−]pub trait UpdateListener: for<'a> AsUpdateStream<'a, StreamErr = Self::Err> {
type Err;
fn stop_token(&mut self) -> StopToken;
fn hint_allowed_updates(
&mut self,
hint: &mut dyn Iterator<Item = AllowedUpdate>
) { ... }
fn timeout_hint(&self) -> Option<Duration> { ... }
}Expand description
An update listener.
Implementors of this trait allow getting updates from Telegram. See module-level documentation for more.
Some functions of this trait are located in the supertrait
(AsUpdateStream), see also:
Required Associated Types
Required Methods
sourcefn stop_token(&mut self) -> StopToken
fn stop_token(&mut self) -> StopToken
Returns a token which stops this listener.
The stop function of the token is not guaranteed to have an
immediate effect. That is, some listeners can return updates even
after stop is called (e.g.: because of buffering).
Implementors of this function are encouraged to stop listening for
updates as soon as possible and return None from the update stream as
soon as all cached updates are returned.
Provided Methods
sourcefn hint_allowed_updates(&mut self, hint: &mut dyn Iterator<Item = AllowedUpdate>)
fn hint_allowed_updates(&mut self, hint: &mut dyn Iterator<Item = AllowedUpdate>)
Hint which updates should the listener listen for.
For example polling() should send the hint as
GetUpdates::allowed_updates
Note however that this is a hint and as such, it can be ignored. The listener is not guaranteed to only return updates which types are listed in the hint.