Trait timer_kit::Delay

source ·
pub trait Delay {
    type Value;
    type Instant: Instant;

    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.

Implementations on Foreign Types§

source§

impl Delay for Sleep

§

type Value = ()

§

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)

source§

impl Delay for Timer

§

type Value = Instant

§

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

§

type Value = ()

§

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)

Implementors§