Struct async_timer::Timed
source · pub struct Timed<'a, F, T = PlatformTimer> { /* 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> RefUnwindSafe for Timed<'a, F, T>where F: RefUnwindSafe, T: RefUnwindSafe,
impl<'a, F, T> Send for Timed<'a, F, T>where F: Send, T: Send,
impl<'a, F, T> Sync for Timed<'a, F, T>where F: Sync, T: Sync,
impl<'a, F, T> Unpin for Timed<'a, F, T>where T: Unpin,
impl<'a, F, T = WinTimer> !UnwindSafe for Timed<'a, F, T>
Blanket Implementations§
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere F: Future,
§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