pub trait BlockingRuntime {
type BlockingIterator<'a, R: 'a>: Iterator<Item = R> + 'a;
// Required methods
fn handle(&self) -> Handle;
fn block_on<Fut, R>(&self, fut: Fut) -> R
where Fut: Future<Output = R>;
fn block_on_stream<'a, S, R>(
&self,
stream: S,
) -> Self::BlockingIterator<'a, R>
where S: Stream<Item = R> + Send + 'a,
R: Send + 'a;
}Expand description
A generic API blocking entry points to runtimes.
Required Associated Types§
Sourcetype BlockingIterator<'a, R: 'a>: Iterator<Item = R> + 'a
type BlockingIterator<'a, R: 'a>: Iterator<Item = R> + 'a
Associated type for the blocking iterator returned by block_on_stream.
Required Methods§
Sourcefn block_on<Fut, R>(&self, fut: Fut) -> Rwhere
Fut: Future<Output = R>,
fn block_on<Fut, R>(&self, fut: Fut) -> Rwhere
Fut: Future<Output = R>,
Runs a future to completion on the runtime, blocking the current thread until it completes.
The future is provided a Handle to the runtime so that it may spawn additional tasks
to be executed concurrently.
Sourcefn block_on_stream<'a, S, R>(&self, stream: S) -> Self::BlockingIterator<'a, R>
fn block_on_stream<'a, S, R>(&self, stream: S) -> Self::BlockingIterator<'a, R>
Returns an iterator wrapper around a stream, blocking the current thread for each item.
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.