pub trait TimerDriver<T: Timer>: Default {
// Required methods
fn insert(
&mut self,
when: Instant,
timer: T,
) -> Result<TimerHandle, InsertError<T>>;
fn cancel(&mut self, handle: TimerHandle) -> Option<T>;
fn poll(
&mut self,
now: Instant,
ctx: &mut T::Context,
) -> Result<usize, PollError>;
}Expand description
Trait for timer driver implementations.
Enables generic runtime code that works with any wheel variant.
Required Methods§
Sourcefn insert(
&mut self,
when: Instant,
timer: T,
) -> Result<TimerHandle, InsertError<T>>
fn insert( &mut self, when: Instant, timer: T, ) -> Result<TimerHandle, InsertError<T>>
Insert a timer to fire at the given instant.
Returns a handle for cancellation, or an error containing the timer if the wheel is at capacity.
Sourcefn cancel(&mut self, handle: TimerHandle) -> Option<T>
fn cancel(&mut self, handle: TimerHandle) -> Option<T>
Cancel a pending timer.
Returns the timer if still pending, None if already fired or invalid handle.
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.