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§
Sourcefn block_on<F: Future>(&self, future: F) -> F::Output
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 Runtime
s 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.
impl ToplevelBlockOn for AsyncStd
native-tls
or rustls
) and (crate features async-std
or tokio
) and crate feature async-std
only.Implementors§
impl ToplevelBlockOn for AsyncStdNativeTlsRuntime
native-tls
or rustls
) and crate feature async-std
only.impl ToplevelBlockOn for AsyncStdRustlsRuntime
native-tls
or rustls
) and crate feature async-std
only.impl ToplevelBlockOn for PreferredRuntime
impl ToplevelBlockOn for TokioNativeTlsRuntime
native-tls
or rustls
) and crate feature tokio
only.impl ToplevelBlockOn for TokioRustlsRuntime
native-tls
or rustls
) and crate feature tokio
only.