[][src]Trait futures_core::stream::Stream

pub trait Stream {
    type Item;
    fn poll_next(
        self: PinMut<Self>,
        cx: &mut Context
    ) -> Poll<Option<Self::Item>>; }

A stream of values produced asynchronously.

If Future<Output = T> is an asynchronous version of T, then Stream<Item = T> is an asynchronous version of Iterator<Item = T>. A stream represents a sequence of value-producing events that occur asynchronously to the caller.

The trait is modeled after Future, but allows poll_next to be called even after a value has been produced, yielding None once the stream has been fully exhausted.

Associated Types

Values yielded by the stream.

Required Methods

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted.

Return value

There are several possible return values, each indicating a distinct stream state:

  • Poll::Pending means that this stream's next value is not ready yet. Implementations will ensure that the current task will be notified when the next value may be ready.

  • Poll::Ready(Some(val)) means that the stream has successfully produced a value, val, and may produce further values on subsequent poll_next calls.

  • Poll::Ready(None) means that the stream has terminated, and poll_next should not be invoked again.

Panics

Once a stream is finished, i.e. Ready(None) has been returned, further calls to poll_next may result in a panic or other "bad behavior". If this is difficult to guard against then the fuse adapter can be used to ensure that poll_next always returns Ready(None) in subsequent calls.

Implementations on Foreign Types

impl<'a, S: ?Sized + Stream + Unpin> Stream for &'a mut S
[src]

impl<'a, S: ?Sized + Stream> Stream for PinMut<'a, S>
[src]

impl<A, B> Stream for Either<A, B> where
    A: Stream,
    B: Stream<Item = A::Item>, 
[src]

impl<S: ?Sized + Stream + Unpin> Stream for Box<S>
[src]

impl<S: ?Sized + Stream> Stream for PinBox<S>
[src]

impl<S: Stream> Stream for AssertUnwindSafe<S>
[src]

impl<T: Unpin> Stream for VecDeque<T>
[src]

Implementors