pub enum Timed<F, T = Timer> {
// some variants omitted
}
Expand description
Limiter on time to wait for underlying Future
§Usage
async fn job() {
}
async fn do_job() {
let work = unsafe {
async_timer::Timed::platform_new_unchecked(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§
Source§impl<F: Future + Unpin> Timed<F>
impl<F: Future + Unpin> Timed<F>
Sourcepub fn platform_new(inner: F, timeout: Duration) -> Self
pub fn platform_new(inner: F, timeout: Duration) -> Self
Creates new instance using Timer alias.
Source§impl<F: Future> Timed<F>
impl<F: Future> Timed<F>
Sourcepub unsafe fn platform_new_unchecked(inner: F, timeout: Duration) -> Self
pub unsafe fn platform_new_unchecked(inner: F, timeout: Duration) -> Self
Creates new instance using Timer alias.
Unsafe version of platform_new
that doesn’t require Unpin
.
Trait Implementations§
Source§impl<F: Future, T: Oneshot> Future for Timed<F, T>
impl<F: Future, T: Oneshot> Future for Timed<F, T>
impl<F: Future + Unpin, T: Oneshot> Unpin for Timed<F, T>
Auto Trait Implementations§
impl<F, T> Freeze for Timed<F, T>
impl<F, T> RefUnwindSafe for Timed<F, T>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<F, T> Send for Timed<F, T>
impl<F, T> Sync for Timed<F, T>
impl<F, T> UnwindSafe for Timed<F, T>where
T: UnwindSafe,
F: UnwindSafe,
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