futures_concurrency::concurrent_stream

Trait Consumer

source
pub trait Consumer<Item, Fut>
where Fut: Future<Output = Item>,
{ type Output; // Required methods async fn send(self: Pin<&mut Self>, fut: Fut) -> ConsumerState; async fn progress(self: Pin<&mut Self>) -> ConsumerState; async fn flush(self: Pin<&mut Self>) -> Self::Output; }
Expand description

Describes a type which can receive data.

§Type Generics

  • Item in this context means the item that it will repeatedly receive.
  • Future in this context refers to the future type repeatedly submitted to it.

Required Associated Types§

source

type Output

What is the type of the item we’re returning when completed?

Required Methods§

source

async fn send(self: Pin<&mut Self>, fut: Fut) -> ConsumerState

Send an item down to the next step in the processing queue.

source

async fn progress(self: Pin<&mut Self>) -> ConsumerState

Make progress on the consumer while doing something else.

It should always be possible to drop the future returned by this function. This is solely intended to keep work going on the Consumer while doing e.g. waiting for new futures from a stream.

source

async fn flush(self: Pin<&mut Self>) -> Self::Output

We have no more data left to send to the Consumer; wait for its output.

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§