pub trait TimerExt: Sealed {
// Required methods
fn timeout<F: Future>(
&self,
delay: Duration,
work: F,
) -> Result<Timeout<F>, TimerRegistrationError>;
fn sleep(&self, delay: Duration) -> Result<Sleep, TimerRegistrationError>;
fn interval(
&self,
period: Duration,
) -> Result<Interval, TimerRegistrationError>;
}Expand description
Timer operations bound to a context’s current generation.
Required Methods§
Sourcefn timeout<F: Future>(
&self,
delay: Duration,
work: F,
) -> Result<Timeout<F>, TimerRegistrationError>
fn timeout<F: Future>( &self, delay: Duration, work: F, ) -> Result<Timeout<F>, TimerRegistrationError>
Construct a complete work-owning Timeout.
The deadline is pinned synchronously while work remains lazy. The
operation owns work; generation cleanup owns only cancellation.
Sourcefn sleep(&self, delay: Duration) -> Result<Sleep, TimerRegistrationError>
fn sleep(&self, delay: Duration) -> Result<Sleep, TimerRegistrationError>
Construct one complete, deadline-pinned Sleep.
Registration is synchronous and fallible. The delay may be zero. The constructor validates generation admission before the Timer environment, pins the monotonic deadline before committing generation cleanup, and returns no operation on any failure.
Sourcefn interval(&self, period: Duration) -> Result<Interval, TimerRegistrationError>
fn interval(&self, period: Duration) -> Result<Interval, TimerRegistrationError>
Construct a fixed-phase Interval anchored at successful construction.
A zero period is rejected before Context admission and Timer environment validation. Missed ticks coalesce without shifting the construction-time phase, and generation cancellation is one explicit terminal stream item.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".