[−][src]Struct cancellable_timer::Timer
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]
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:
- Ok(()) if the given time has elapsed.
- An Error of kind ErrorKind::Interrupted if the timer has been cancelled.
- Some other Error if something goes wrong.
pub fn after<F>(wait: Duration, callback: F) -> Result<Canceller> where
F: FnOnce(Result<()>),
F: Send + 'static,
[src]
F: FnOnce(Result<()>),
F: Send + 'static,
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:
- Ok(()) if the amount of time has elapsed.
- An Error of kind ErrorKind::Interrupted if the timer has been cancelled.
- Some other Error if something goes wrong.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,