Trait ToplevelBlockOn

Source
pub trait ToplevelBlockOn:
    Clone
    + Send
    + Sync
    + 'static {
    // Required method
    fn block_on<F: Future>(&self, future: F) -> F::Output;
}
Expand description

Trait for a runtime that can be entered to block on a toplevel future.

This trait is not implied by Runtime, only by ToplevelRuntime. ToplevelRuntime is available at the toplevel of each program, typically, where a concrete async executor is selected.

Required Methods§

Source

fn block_on<F: Future>(&self, future: F) -> F::Output

Run future until it is ready, and return its output.

§Not reentrant!

There should be one call to block_on (for each fresh Runtime), at the toplevel of the program (or test case). (Sequential calls to block_on from the same thread are allowed.)

block_on may not function correctly if is called from multiple threads simultaneously, or if calls involving different Runtimes are interleaved on the same thread. (Specific runtimes may offer better guarantees.)

(tor_rtmock::MockExecutor’s implementation will often detect violations.)

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.

Implementations on Foreign Types§

Source§

impl ToplevelBlockOn for AsyncStd

Available on (crate features native-tls or rustls) and (crate features async-std or tokio) and crate feature async-std only.
Source§

fn block_on<F: Future>(&self, f: F) -> F::Output

Implementors§

Source§

impl ToplevelBlockOn for AsyncStdNativeTlsRuntime

Available on (crate features native-tls or rustls) and crate feature async-std only.
Source§

impl ToplevelBlockOn for AsyncStdRustlsRuntime

Available on (crate features native-tls or rustls) and crate feature async-std only.
Source§

impl ToplevelBlockOn for PreferredRuntime

Source§

impl ToplevelBlockOn for TokioNativeTlsRuntime

Available on (crate features native-tls or rustls) and crate feature tokio only.
Source§

impl ToplevelBlockOn for TokioRustlsRuntime

Available on (crate features native-tls or rustls) and crate feature tokio only.
Source§

impl<TaskR, SleepR, CoarseTimeR, TcpR, UnixR, TlsR, UdpR> ToplevelBlockOn for CompoundRuntime<TaskR, SleepR, CoarseTimeR, TcpR, UnixR, TlsR, UdpR>
where TaskR: ToplevelBlockOn, SleepR: Clone + Send + Sync + 'static, CoarseTimeR: Clone + Send + Sync + 'static, TcpR: Clone + Send + Sync + 'static, UnixR: Clone + Send + Sync + 'static, TlsR: Clone + Send + Sync + 'static, UdpR: Clone + Send + Sync + 'static,