[−][src]Struct riddle_time::TimerHandle
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,