logo
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

The type of errors that can be returned from this listener.

Required Methods

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

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.

The timeout duration hint.

This hints how often dispatcher should check for a shutdown. E.g., for polling() this returns the timeout.

If you are implementing this trait and not sure what to return from this function, just leave it with the default implementation.

Implementors