Trait base::TimerTrait

source ·
pub trait TimerTrait: AsRawDescriptor + IntoRawDescriptor + Send {
    // Required methods
    fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()>;
    fn wait(&mut self) -> Result<()>;
    fn mark_waited(&mut self) -> Result<bool>;
    fn clear(&mut self) -> Result<()>;
    fn resolution(&self) -> Result<Duration>;
Expand description

A trait for timer objects that delivers timer expiration notifications to an underlying descriptor.

Required Methods§


fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()>

Sets the timer to expire after dur. If interval is not None and non-zero it represents the period for repeated expirations after the initial expiration. Otherwise the timer will expire just once. Cancels any existing duration and repeating interval.


fn wait(&mut self) -> Result<()>

Waits until the timer expires.


fn mark_waited(&mut self) -> Result<bool>

After a timer is triggered from an EventContext, mark the timer as having been waited for. If a timer is not marked waited, it will immediately trigger the event context again. This does not need to be called after calling Timer::wait.

Returns true if the timer has been adjusted since the EventContext was triggered by this timer.


fn clear(&mut self) -> Result<()>

Disarms the timer.


fn resolution(&self) -> Result<Duration>

Returns the resolution of timers on the host.