pub trait TimeInterval: Unpin + Send {
// Required method
fn poll_tick(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Instant>;
// Provided methods
fn tick(self) -> TickFuture<Self> ⓘ
where Self: Sized { ... }
fn into_stream(self) -> IntervalStream<Self>
where Self: Sized { ... }
}Expand description
Trait for periodic timers.
This trait defines the interface for periodic timers that can be used to implement recurring tasks.
Required Methods§
Provided Methods§
Sourcefn tick(self) -> TickFuture<Self> ⓘwhere
Self: Sized,
fn tick(self) -> TickFuture<Self> ⓘwhere
Self: Sized,
Wait asynchronously for the next tick.
This method returns a future that completes when the next timer tick occurs.
§Returns
A future that resolves to the instant when the tick occurred.
Sourcefn into_stream(self) -> IntervalStream<Self>where
Self: Sized,
fn into_stream(self) -> IntervalStream<Self>where
Self: Sized,
Convert this interval into a stream.
This method converts the interval into a stream that yields the instant of each tick.
§Returns
A stream that yields the instant of each tick.