pub struct Timed<'a, F, T = Platform> { /* private fields */ }
Expand description
Limiter on time to wait for underlying Future
§Usage
async fn job() {
}
async fn do_job() {
let mut job = job();
let job = unsafe {
core::pin::Pin::new_unchecked(&mut job)
};
let work = unsafe {
async_timer::Timed::platform_new(job, core::time::Duration::from_secs(1))
};
match work.await {
Ok(_) => println!("I'm done!"),
//You can retry by polling `expired`
Err(expired) => println!("Job expired: {}", expired),
}
}
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a, F, T> Freeze for Timed<'a, F, T>where
T: Freeze,
impl<'a, F, T> RefUnwindSafe for Timed<'a, F, T>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<'a, F, T> Send for Timed<'a, F, T>
impl<'a, F, T> Sync for Timed<'a, F, T>
impl<'a, F, T> Unpin for Timed<'a, F, T>where
T: Unpin,
impl<'a, F, T = AppleTimer> !UnwindSafe for Timed<'a, F, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more