Struct riddle_time::TimerHandle[][src]

pub struct TimerHandle { /* fields omitted */ }

A handle to a timer created by crate::TimeSystem::register_timer.

It can be used to detect whether the timer has triggered, and to cancel the timer if it hasn’t been triggered yet.

Implementations

impl TimerHandle[src]

pub fn cancel(&self)[src]

Cancel a pending timer.

If the timer has already fired, or been cancelled, this is a no-op.

Example

let timer_handle = time_system.register_timer(Duration::from_millis(200),
    move || { panic!("The timer should never fire"); }
);

timer_handle.cancel();

// The panic! never fires because the timer was cancelled.

pub fn pending(&self) -> bool[src]

Check whether a timer has yet to fire.

If the timer was cancelled before it was fired, this will remain true.

Example

let timer_handle = time_system.register_timer(Duration::from_millis(200), || {});

assert_eq!(true, timer_handle.pending());

// A while later
// The timer has fired and is no longer pending
assert_eq!(false, timer_handle.pending());

Auto Trait Implementations

impl RefUnwindSafe for TimerHandle

impl Send for TimerHandle

impl Sync for TimerHandle

impl Unpin for TimerHandle

impl UnwindSafe for TimerHandle

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.