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:
Type | Feature | Target 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§
Required Methods§
Sourcefn delay_until(deadline: Self::Instant) -> Self
fn delay_until(deadline: Self::Instant) -> Self
Creates a new delay with a specified deadline.
Sourcefn deadline(&self) -> Option<Self::Instant>
fn deadline(&self) -> Option<Self::Instant>
Some implementation do not expose the deadline, so this is an optional.
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.