Skip to main content

Stream

Trait Stream 

Source
pub trait Stream {
    type Item;

    // Required method
    fn poll_next(
        self: Pin<&mut Self>,
        context: &mut Context<'_>,
    ) -> Poll<Option<Self::Item>>;
}
Expand description

A stream of values that arrive one at a time, asynchronously.

The one shape PrinterPort::push_events answers in, declared here so that this port depends on nothing but the type crate. It is the same contract as the ecosystem’s own Stream: Ready(None) is the end, after which nothing more arrives.

Required Associated Types§

Source

type Item

What the stream yields.

Required Methods§

Source

fn poll_next( self: Pin<&mut Self>, context: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Take the next value when one has arrived, Ready(None) at the end, or Pending — having arranged for the context’s waker to be woken when either is ready.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§