TimeInterval

Trait TimeInterval 

Source
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§

Source

fn poll_tick(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll<Instant>

Poll for the next tick.

This method is used internally by the async runtime to check if the next timer tick is ready.

§Parameters
  • ctx - The task context for polling
§Returns

A Poll containing the instant when the tick occurred, or Poll::Pending if the tick is not yet ready.

Provided Methods§

Source

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.

Source

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.

Implementors§