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
sourceimpl 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
sourceimpl EventSource for Timer
impl EventSource for Timer
type Ret = TimeoutAction
type Ret = TimeoutAction
The return type of the user callback Read more
type Error = Error
type Error = Error
The error type returned from
process_events() (not the user callback!). Read more
sourcefn process_events<F>(
&mut self,
_: Readiness,
token: Token,
callback: F
) -> Result<PostAction, Self::Error> where
F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,
fn process_events<F>(
&mut self,
_: Readiness,
token: Token,
callback: F
) -> Result<PostAction, Self::Error> where
F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,
Process any relevant events Read more
sourcefn register(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
fn register(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
Register yourself to this poll instance Read more
sourcefn reregister(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
fn reregister(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
Re-register your file descriptors Read more
sourcefn unregister(&mut self, poll: &mut Poll) -> Result<()>
fn unregister(&mut self, poll: &mut Poll) -> Result<()>
Unregister your file descriptors Read more
Auto Trait Implementations
impl !RefUnwindSafe for Timer
impl !Send for Timer
impl !Sync for Timer
impl Unpin for Timer
impl !UnwindSafe for Timer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more