Struct tbot::event_loop::Polling
source · pub struct Polling { /* private fields */ }
Expand description
Configures and starts polling.
To construct Polling
, use EventLoop::polling
.
Implementations§
source§impl Polling
impl Polling
sourcepub fn into_stateful<S>(self, state: S) -> Polling<S>where
S: Send + Sync + 'static,
pub fn into_stateful<S>(self, state: S) -> Polling<S>where
S: Send + Sync + 'static,
Turns this polling into a stateful one. Previous configuration
sourcepub const fn allowed_updates(self, allowed_updates: AllowedUpdates) -> Self
pub const fn allowed_updates(self, allowed_updates: AllowedUpdates) -> Self
Configures which updates you’d like to listen to.
sourcepub fn error_handler<H, F>(self, handler: H) -> Selfwhere
H: Fn(Polling) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
pub fn error_handler<H, F>(self, handler: H) -> Selfwhere
H: Fn(Polling) -> F + Send + Sync + 'static,
F: Future<Output = ()> + Send + 'static,
Adds a handler for errors ocurred while polling.
sourcepub const fn poll_interval(self, poll_interval: Duration) -> Self
pub const fn poll_interval(self, poll_interval: Duration) -> Self
Configures the minimal interval between making requests. Set to 25ms
by default.
sourcepub const fn request_timeout(self, timeout: Duration) -> Self
pub const fn request_timeout(self, timeout: Duration) -> Self
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)
.
sourcepub fn last_n_updates(self, n: NonZeroUsize) -> Self
pub fn last_n_updates(self, n: NonZeroUsize) -> Self
Configures how many updates tbot
will process on start. If configured,
tbot
sets offset
’s value to -n
when making the first request.
Panics
Panics if n
can’t be converted to isize
safely.
source§impl Polling
impl Polling
sourcepub async fn start(self) -> Result<Infallible, PollingSetup>
pub async fn start(self) -> Result<Infallible, PollingSetup>
Starts the event loop.