pub trait FutureExt: IntoFuture {
// Provided methods
fn block_on(self) -> Self::Output
where Self: Sized { ... }
fn wait_timeout(self, timeout: Duration) -> Option<Self::Output>
where Self: Sized { ... }
}blocking only.Expand description
Extension methods for waiting on a future from synchronous code.
§Example
use std::time::Duration;
use asyncband::blocking::FutureExt as _;
assert_eq!(async { 42 }.block_on(), 42);
assert_eq!(async { 42 }.wait_timeout(Duration::ZERO), Some(42));Provided Methods§
Sourcefn block_on(self) -> Self::Outputwhere
Self: Sized,
fn block_on(self) -> Self::Outputwhere
Self: Sized,
Blocks the current thread until this future is ready.
See the blocking module documentation for runtime limitations and
executor-thread caveats.
Sourcefn wait_timeout(self, timeout: Duration) -> Option<Self::Output>where
Self: Sized,
fn wait_timeout(self, timeout: Duration) -> Option<Self::Output>where
Self: Sized,
Blocks the current thread until this future is ready or timeout elapses.
The future is polled before checking the timeout, so an immediately ready future succeeds
even when timeout is zero. Returns None on timeout and drops the future, cancelling it
according to that future’s cancellation semantics.
The timeout cannot interrupt a call to Future::poll. See the
blocking module documentation for other runtime limitations and
executor-thread caveats.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".