pub struct Timeout<'bemly_, Content> { /* private fields */ }Available on crate feature
nano-alloc only.Expand description
A wrapper that adds a time limit to a Future.
If the internal future does not complete before the deadline (in hardware ticks),
it returns Err(()). Otherwise, it returns Ok(Output).
§Examples
use uefi_async::nano_alloc::time::Timeout;
async fn calc_1() {}
async fn calc_2() {
match Box::pin(calc_2()).timeout(Duration::from_secs(2).as_secs()).await { _ => () }
match Timeout::new_pin(Box::pin(calc_2()), 500).await { _ => () }
match Timeout::new(calc_1(), 300).await { _ => () }
match calc_2().timeout(500).await { Ok(_) => {}, Err(_) => {} }
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'bemly_, Content> Freeze for Timeout<'bemly_, Content>
impl<'bemly_, Content> !RefUnwindSafe for Timeout<'bemly_, Content>
impl<'bemly_, Content> !Send for Timeout<'bemly_, Content>
impl<'bemly_, Content> !Sync for Timeout<'bemly_, Content>
impl<'bemly_, Content> Unpin for Timeout<'bemly_, Content>
impl<'bemly_, Content> !UnwindSafe for Timeout<'bemly_, Content>
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> FutureExt for F
impl<F> FutureExt for F
Source§impl<F1> FutureExt for F1where
F1: Future,
impl<F1> FutureExt for F1where
F1: Future,
Source§fn join<F2>(self, other: F2) -> Join2<F1, <F2 as IntoFuture>::IntoFuture>where
F1: Future,
F2: IntoFuture,
fn join<F2>(self, other: F2) -> Join2<F1, <F2 as IntoFuture>::IntoFuture>where
F1: Future,
F2: IntoFuture,
Wait for both futures to complete.
Source§fn race<T, S2>(self, other: S2) -> Race2<T, F1, <S2 as IntoFuture>::IntoFuture>where
F1: Future<Output = T>,
S2: IntoFuture<Output = T>,
fn race<T, S2>(self, other: S2) -> Race2<T, F1, <S2 as IntoFuture>::IntoFuture>where
F1: Future<Output = T>,
S2: IntoFuture<Output = T>,
Wait for the first future to complete.
Source§fn wait_until<D>(
self,
deadline: D,
) -> WaitUntil<Self, <D as IntoFuture>::IntoFuture> ⓘwhere
Self: Sized,
D: IntoFuture,
fn wait_until<D>(
self,
deadline: D,
) -> WaitUntil<Self, <D as IntoFuture>::IntoFuture> ⓘwhere
Self: Sized,
D: IntoFuture,
Delay resolving the future until the given deadline. 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