Trait agnostic_lite::AsyncInterval
source · pub trait AsyncInterval: Stream<Item = Instant> {
// Required methods
fn reset(&mut self, interval: Duration);
fn reset_at(&mut self, instant: Instant);
fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>;
}Expand description
The interval abstraction for a runtime.
Required Methods§
sourcefn reset_at(&mut self, instant: Instant)
fn reset_at(&mut self, instant: Instant)
Resets the interval to a specific instant. Sets the next tick to expire at the given instant.
The behavior of this function may different in different runtime implementations.
sourcefn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>
fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant>
Polls for the next instant in the interval to be reached.
This method can return the following values:
Poll::Pendingif the next instant has not yet been reached.Poll::Ready(instant)if the next instant has been reached.
When this method returns Poll::Pending, the current task is scheduled
to receive a wakeup when the instant has elapsed. Note that on multiple
calls to poll_tick, only the Waker from the
Context passed to the most recent call is scheduled to receive a
wakeup.