Struct tbot::state::Polling[][src]

#[must_use = "polling does nothing unless `start` is called"]
pub struct Polling<S> { /* fields omitted */ }

Configures and starts polling for the stateful event loop.

To construct Polling, use StatefulEventLoop::polling.


impl<S> Polling<S>[src]

pub fn into_stateless(self) -> Polling[src]

Turns this polling into a stateless one. Previous configuration

pub fn with_other_state<T>(self, other_state: T) -> Polling<T> where
    T: Send + Sync + 'static, 

Turns this polling into another with other state.

pub fn limit(self, limit: u8) -> Self[src]

Configures the limit of updates per request.

pub fn timeout(self, timeout: u64) -> Self[src]

Configures the timeout for long polling.

pub fn allowed_updates(self, allowed_updates: AllowedUpdates) -> Self[src]

Configures which updates you’d like to listen to.

pub fn poll_interval(self, poll_interval: Duration) -> Self[src]

Configures the minimal interval between making requests. Set to 25ms by default.

pub fn request_timeout(self, timeout: Duration) -> Self[src]

Configures for how long tbot should wait for getUpdates. If this timeout is exceeded, the error handler is triggered. If you don’t configure this value, it is set to Duration::from_secs(timeout.unwrap_or(0) + 60).

pub fn last_n_updates(self, n: NonZeroUsize) -> Self[src]

Configures how many updates tbot will process on start. If configured, tbot sets offset’s value to -n when making the first request.


Panics if n can’t be converted to isize safely.

pub async fn start(self) -> Result<Infallible, PollingSetup>[src]

Starts the event loop.

impl<S> Polling<S> where
    S: Send + Sync + 'static, 

pub fn error_handler<H, F>(self, handler: H) -> Self where
    H: Fn(Polling, Arc<S>) -> F + Send + Sync + 'static,
    F: Future<Output = ()> + Send + 'static, 

Adds a handler for errors ocurred while polling.

Auto Trait Implementations

impl<S> !RefUnwindSafe for Polling<S>

impl<S> Send for Polling<S> where
    S: Send + Sync

impl<S> Sync for Polling<S> where
    S: Send + Sync

impl<S> Unpin for Polling<S>

impl<S> !UnwindSafe for Polling<S>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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.