[][src]Trait futures::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<St, F, T> Stream for MapOk<St, F> where
    F: FnMut(<St as TryStream>::Ok) -> T,
    St: TryStream
[src]

impl<St, F, E> Stream for MapErr<St, F> where
    F: FnMut(<St as TryStream>::Error) -> E,
    St: TryStream
[src]

impl<St, Fut, F, T> Stream for TryFilterMap<St, Fut, F> where
    F: FnMut(<St as TryStream>::Ok) -> Fut,
    Fut: TryFuture<Ok = Option<T>, Error = <St as TryStream>::Error>,
    St: TryStream
[src]

impl<S, U, St, F> Stream for WithFlatMap<S, U, St, F> where
    F: FnMut(U) -> St,
    S: Stream + Sink,
    St: Stream<Item = Result<<S as Sink>::SinkItem, <S as Sink>::SinkError>>, 
[src]

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

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

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

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

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

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

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

Implementors