[][src]Struct cancellable_timer::Timer

pub struct Timer { /* fields omitted */ }

A timer object that can be used to put the current thread to sleep or to start a callback after a given amount of time.

Methods

impl Timer[src]

pub fn new2() -> Result<(Self, Canceller)>[src]

Create a Timer and its associated Canceller.

pub fn sleep(&mut self, duration: Duration) -> Result<()>[src]

Put the current thread to sleep until the given time has elapsed or the timer is cancelled.

Returns:

pub fn after<F>(wait: Duration, callback: F) -> Result<Canceller> where
    F: FnOnce(Result<()>),
    F: Send + 'static, 
[src]

Run a callback on a new thread after a specified amount of time. The callback is not run if after returns an error.

Otherwise, the callback is given:

Auto Trait Implementations

impl Send for Timer

impl Sync for Timer

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.