pub struct Timeout<F> { /* private fields */ }
Available on WASI only.
Expand description
A future that resolves to None
after a certain amount of time, if the
provided future has not resolved yet.
§Example
let future = async {
// do some work
};
let result = timeout(Duration::from_secs(1), future).await;
if let Some(result) = result {
// do something with the result
} else {
// the future timed out
}
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for Timeout<F>where
F: Freeze,
impl<F> RefUnwindSafe for Timeout<F>where
F: RefUnwindSafe,
impl<F> Send for Timeout<F>where
F: Send,
impl<F> Sync for Timeout<F>where
F: Sync,
impl<F> Unpin for Timeout<F>where
F: Unpin,
impl<F> UnwindSafe for Timeout<F>where
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