TimerStrategy

Trait TimerStrategy 

Source
pub trait TimerStrategy<S: Sleep>: Send {
    // Required methods
    fn initial(&self) -> Instant;
    fn sleep(
        &self,
        old: Instant,
        interval: Duration,
    ) -> impl Future<Output = Instant> + Send;
}
Available on crate feature async only.
Expand description

A trait for timer strategies.

Required Methods§

Source

fn initial(&self) -> Instant

Returns the initial instant.

Source

fn sleep( &self, old: Instant, interval: Duration, ) -> impl Future<Output = Instant> + Send

Sleep until the specified time. The first call receives the return value of TimerStrategy::initial as old, and subsequent calls receive the previous return value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S: Sleep> TimerStrategy<S> for FixedDelay<S>

Source§

impl<S: Sleep> TimerStrategy<S> for FixedSchedule<S>