pub trait TimerProvider {
// Required methods
fn schedule(&mut self, id: u64, delay_ms: u32) -> Result<u64, TimerError>;
fn cancel(&mut self, id: u64) -> Result<bool, TimerError>;
fn poll_expired(
&mut self,
output: &mut Vec<TimerWakeup>,
) -> Result<(), TimerError>;
fn wait_expired(&mut self) -> Result<Option<TimerWakeup>, TimerError>;
fn has_pending(&self) -> bool;
}Expand description
A host capability that schedules real time without observing machine state.
The provider owns only opaque u64 identifiers and monotonic millisecond
deadlines; it never stores a JavaScript Value. The machine owns visible
ordering and every callback identity.
Required Methods§
Sourcefn schedule(&mut self, id: u64, delay_ms: u32) -> Result<u64, TimerError>
fn schedule(&mut self, id: u64, delay_ms: u32) -> Result<u64, TimerError>
Arms a timer for id after at least delay_ms milliseconds, returning
the provider-monotonic absolute-millisecond deadline.
Sourcefn cancel(&mut self, id: u64) -> Result<bool, TimerError>
fn cancel(&mut self, id: u64) -> Result<bool, TimerError>
Cancels the armed timer for id, returning whether one was removed.
Sourcefn poll_expired(
&mut self,
output: &mut Vec<TimerWakeup>,
) -> Result<(), TimerError>
fn poll_expired( &mut self, output: &mut Vec<TimerWakeup>, ) -> Result<(), TimerError>
Drains every currently expired timer into output without blocking.
Sourcefn wait_expired(&mut self) -> Result<Option<TimerWakeup>, TimerError>
fn wait_expired(&mut self) -> Result<Option<TimerWakeup>, TimerError>
Blocks until the next timer expires, or returns None when none pend.
Sourcefn has_pending(&self) -> bool
fn has_pending(&self) -> bool
Reports whether the provider has any armed timer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".