Trait Delay

Source
pub trait Delay {
    type Value;
    type Instant: Instant;

    // Required methods
    fn delay(duration: Duration) -> Self;
    fn delay_until(deadline: Self::Instant) -> Self;
    fn deadline(&self) -> Option<Self::Instant>;
    fn poll_elapsed(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Self::Value>;
    fn reset(self: Pin<&mut Self>, deadline: Self::Instant);
}
Expand description

A trait that defines a delay, which is the fundamental building block of this crate.

§Implementations

Implementations for the following types are provided with the corresponding features enabled:

TypeFeatureTarget Arch
tokio::time::Sleep"tokio"non-wasm32
smol::Timer"smol"non-wasm32
futures_timer::Delay"futures-timer"non-wasm32
[wasm_timer::Delay]"wasm-timer"wasm32
[fluvio_wasm_timer::Delay]"fluvio-wasm-timer"wasm32

User could also provide their own implementations for other types to use the timer functionalities provided by this crate.

Required Associated Types§

Source

type Value

The type of value returned by the delay upon completion of poll_elapsed.

Source

type Instant: Instant

The type of instant used by the delay.

Required Methods§

Source

fn delay(duration: Duration) -> Self

Creates a new delay with a specified duration.

Source

fn delay_until(deadline: Self::Instant) -> Self

Creates a new delay with a specified deadline.

Source

fn deadline(&self) -> Option<Self::Instant>

Some implementation do not expose the deadline, so this is an optional.

Source

fn poll_elapsed(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Value>

Polls the delay for completion.

Source

fn reset(self: Pin<&mut Self>, deadline: Self::Instant)

Resets the delay to a new deadline.

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.

Implementations on Foreign Types§

Source§

impl Delay for Timer

Source§

type Value = Instant

Source§

type Instant = Instant

Source§

fn delay(duration: Duration) -> Self

Source§

fn delay_until(deadline: Self::Instant) -> Self

Source§

fn deadline(&self) -> Option<Self::Instant>

Source§

fn poll_elapsed(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Value>

Source§

fn reset(self: Pin<&mut Self>, deadline: Self::Instant)

Source§

impl Delay for Delay

Source§

type Value = ()

Source§

type Instant = Instant

Source§

fn delay(duration: Duration) -> Self

Source§

fn delay_until(deadline: Self::Instant) -> Self

Source§

fn deadline(&self) -> Option<Self::Instant>

Source§

fn poll_elapsed(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Value>

Source§

fn reset(self: Pin<&mut Self>, deadline: Self::Instant)

Source§

impl Delay for Sleep

Source§

type Value = ()

Source§

type Instant = Instant

Source§

fn delay(duration: Duration) -> Self

Source§

fn delay_until(deadline: Instant) -> Self

Source§

fn deadline(&self) -> Option<Instant>

Source§

fn poll_elapsed(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Value>

Source§

fn reset(self: Pin<&mut Self>, deadline: Instant)

Implementors§