Skip to main content

BlockingRuntime

Trait BlockingRuntime 

Source
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§

Source

type BlockingIterator<'a, R: 'a>: Iterator<Item = R> + 'a

Associated type for the blocking iterator returned by block_on_stream.

Required Methods§

Source

fn handle(&self) -> Handle

Returns a handle to the runtime.

Source

fn block_on<Fut, R>(&self, fut: Fut) -> R
where 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.

Source

fn block_on_stream<'a, S, R>(&self, stream: S) -> Self::BlockingIterator<'a, R>
where S: Stream<Item = R> + Send + 'a, R: Send + 'a,

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".

Implementors§