Skip to main content

BlockingFutureExt

Trait BlockingFutureExt 

Source
pub trait BlockingFutureExt: Sized + Future {
    // Provided methods
    fn wait(self) -> Self::Output { ... }
    fn wait_timeout(
        self,
        timeout: Duration,
    ) -> Result<Self::Output, WaitErr<Self>>
       where Self: Unpin { ... }
}
Expand description

Extension methods for blocking on futures from synchronous code.

Async callers should .await futures directly. These methods are intended for callers that deliberately want to bridge back into a synchronous context.

Provided Methods§

Source

fn wait(self) -> Self::Output

Block until the future completes and return its output.

Source

fn wait_timeout(self, timeout: Duration) -> Result<Self::Output, WaitErr<Self>>
where Self: Unpin,

Block until the future completes or the timeout expires.

If the timeout expires, the future itself is returned, so it can be retried later.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F> BlockingFutureExt for F
where F: Future,