pub struct Timer { /* private fields */ }
Expand description
A timer event source
When registered to the event loop, it will trigger an event once its deadline is reached.
If the deadline is in the past relative to the moment of its insertion in the event loop,
the TImer
will trigger an event as soon as the event loop is dispatched.
Implementations§
source§impl Timer
impl Timer
sourcepub fn immediate() -> Timer
pub fn immediate() -> Timer
Create a timer that will fire immediately when inserted in the event loop
sourcepub fn from_duration(duration: Duration) -> Timer
pub fn from_duration(duration: Duration) -> Timer
Create a timer that will fire after a given duration from now
sourcepub fn from_deadline(deadline: Instant) -> Timer
pub fn from_deadline(deadline: Instant) -> Timer
Create a timer that will fire at a given instant
sourcepub fn set_deadline(&mut self, deadline: Instant)
pub fn set_deadline(&mut self, deadline: Instant)
Changes the deadline of this timer to an Instant
If the Timer
is currently registered in the event loop, it needs to be
re-registered for this change to take effect.
sourcepub fn set_duration(&mut self, duration: Duration)
pub fn set_duration(&mut self, duration: Duration)
Changes the deadline of this timer to a Duration
from now
If the Timer
is currently registered in the event loop, it needs to be
re-registered for this change to take effect.
sourcepub fn current_deadline(&self) -> Instant
pub fn current_deadline(&self) -> Instant
Get the current deadline of this Timer
Trait Implementations§
source§impl EventSource for Timer
impl EventSource for Timer
§type Ret = TimeoutAction
type Ret = TimeoutAction
§type Error = Error
type Error = Error
process_events()
(not the user callback!).