[−][src]Trait futures_core::stream::Stream
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
Required methods
fn poll_next(self: Pin<&mut Self>, waker: &Waker) -> Poll<Option<Self::Item>>
[−]
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 subsequentpoll_next
calls. -
Poll::Ready(None)
means that the stream has terminated, andpoll_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][−]
type Item = S::Item
fn poll_next(self: Pin<&mut Self>, waker: &Waker) -> Poll<Option<Self::Item>>
[src]
impl<P> Stream for Pin<P> where
P: DerefMut + Unpin,
P::Target: Stream,
[src][−]
P: DerefMut + Unpin,
P::Target: Stream,
type Item = <P::Target as Stream>::Item
fn poll_next(self: Pin<&mut Self>, waker: &Waker) -> Poll<Option<Self::Item>>
[src]
impl<A, B> Stream for Either<A, B> where
A: Stream,
B: Stream<Item = A::Item>,
[src][−]
A: Stream,
B: Stream<Item = A::Item>,
impl<S: ?Sized + Stream + Unpin> Stream for Box<S>
[src][−]
type Item = S::Item
fn poll_next(self: Pin<&mut Self>, waker: &Waker) -> Poll<Option<Self::Item>>
[src]
impl<S: Stream> Stream for AssertUnwindSafe<S>
[src][−]
impl<T: Unpin> Stream for VecDeque<T>
[src][−]
Implementors
impl<'a, T> Stream for LocalStreamObj<'a, T>
[src][−]
impl<'a, T> Stream for StreamObj<'a, T>
[src][−]
impl<T> Stream for Receiver<T>
impl<T> Stream for Receiver<T>
impl<T> Stream for UnboundedReceiver<T>
impl<T> Stream for UnboundedReceiver<T>
impl<Fut> Stream for FlattenStream<Fut> where
Fut: Future,
Fut::Output: Stream,
impl<Fut> Stream for FlattenStream<Fut> where
Fut: Future,
Fut::Output: Stream,
impl<Fut: Future> Stream for IntoStream<Fut>
impl<Fut: Future> Stream for IntoStream<Fut>
impl<I> Stream for Iter<I> where
I: Iterator,
impl<I> Stream for Iter<I> where
I: Iterator,
impl<T> Stream for Repeat<T> where
T: Clone,
impl<T> Stream for Repeat<T> where
T: Clone,
impl<St1, St2> Stream for Chain<St1, St2> where
St1: Stream,
St2: Stream<Item = St1::Item>,
impl<St1, St2> Stream for Chain<St1, St2> where
St1: Stream,
St2: Stream<Item = St1::Item>,
impl<T> Stream for Empty<T>
impl<T> Stream for Empty<T>
impl<St, Fut, F> Stream for Filter<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St, Fut, F> Stream for Filter<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St, Fut, F, T> Stream for FilterMap<St, Fut, F> where
St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future<Output = Option<T>>,
impl<St, Fut, F, T> Stream for FilterMap<St, Fut, F> where
St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future<Output = Option<T>>,
impl<St> Stream for Flatten<St> where
St: Stream,
St::Item: Stream,
impl<St> Stream for Flatten<St> where
St: Stream,
St::Item: Stream,
impl<S: Stream> Stream for Fuse<S>
impl<S: Stream> Stream for Fuse<S>
impl<St, F> Stream for Inspect<St, F> where
St: Stream,
F: FnMut(&St::Item),
impl<St, F> Stream for Inspect<St, F> where
St: Stream,
F: FnMut(&St::Item),
impl<St, F, T> Stream for Map<St, F> where
St: Stream,
F: FnMut(St::Item) -> T,
impl<St, F, T> Stream for Map<St, F> where
St: Stream,
F: FnMut(St::Item) -> T,
impl<Fut: Future> Stream for Once<Fut>
impl<Fut: Future> Stream for Once<Fut>
impl<S: Stream> Stream for Peekable<S>
impl<S: Stream> Stream for Peekable<S>
impl<T, F> Stream for PollFn<F> where
F: FnMut(&Waker) -> Poll<Option<T>>,
impl<T, F> Stream for PollFn<F> where
F: FnMut(&Waker) -> Poll<Option<T>>,
impl<St1, St2> Stream for Select<St1, St2> where
St1: Stream,
St2: Stream<Item = St1::Item>,
impl<St1, St2> Stream for Select<St1, St2> where
St1: Stream,
St2: Stream<Item = St1::Item>,
impl<St: Stream> Stream for Skip<St>
impl<St: Stream> Stream for Skip<St>
impl<St, Fut, F> Stream for SkipWhile<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St, Fut, F> Stream for SkipWhile<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St> Stream for Take<St> where
St: Stream,
impl<St> Stream for Take<St> where
St: Stream,
impl<St, Fut, F> Stream for TakeWhile<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St, Fut, F> Stream for TakeWhile<St, Fut, F> where
St: Stream,
F: FnMut(&St::Item) -> Fut,
Fut: Future<Output = bool>,
impl<St, Fut, F> Stream for Then<St, Fut, F> where
St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future,
impl<St, Fut, F> Stream for Then<St, Fut, F> where
St: Stream,
F: FnMut(St::Item) -> Fut,
Fut: Future,
impl<T, F, Fut, It> Stream for Unfold<T, F, Fut> where
F: FnMut(T) -> Fut,
Fut: Future<Output = Option<(It, T)>>,
impl<T, F, Fut, It> Stream for Unfold<T, F, Fut> where
F: FnMut(T) -> Fut,
Fut: Future<Output = Option<(It, T)>>,
impl<St1, St2> Stream for Zip<St1, St2> where
St1: Stream,
St2: Stream,
impl<St1, St2> Stream for Zip<St1, St2> where
St1: Stream,
St2: Stream,
impl<St> Stream for BufferUnordered<St> where
St: Stream,
St::Item: Future,
impl<St> Stream for BufferUnordered<St> where
St: Stream,
St::Item: Future,
impl<St> Stream for Buffered<St> where
St: Stream,
St::Item: Future,
impl<St> Stream for Buffered<St> where
St: Stream,
St::Item: Future,
impl<St: Stream + UnwindSafe> Stream for CatchUnwind<St>
impl<St: Stream + UnwindSafe> Stream for CatchUnwind<St>
impl<St: Stream> Stream for Chunks<St>
impl<St: Stream> Stream for Chunks<St>
impl<Fut: Future> Stream for FuturesOrdered<Fut>
impl<Fut: Future> Stream for FuturesOrdered<Fut>
impl<Fut: Future> Stream for FuturesUnordered<Fut>
impl<Fut: Future> Stream for FuturesUnordered<Fut>
impl<S: Stream> Stream for SplitStream<S>
impl<S: Stream> Stream for SplitStream<S>
impl<St: Stream + Unpin> Stream for SelectAll<St>
impl<St: Stream + Unpin> Stream for SelectAll<St>
impl<St, E> Stream for ErrInto<St, E> where
St: TryStream,
St::Error: Into<E>,
impl<St, E> Stream for ErrInto<St, E> where
St: TryStream,
St::Error: Into<E>,
impl<St: TryStream> Stream for IntoStream<St>
impl<St: TryStream> Stream for IntoStream<St>
impl<St, F, T> Stream for MapOk<St, F> where
St: TryStream,
F: FnMut(St::Ok) -> T,
impl<St, F, T> Stream for MapOk<St, F> where
St: TryStream,
F: FnMut(St::Ok) -> T,
impl<St, F, E> Stream for MapErr<St, F> where
St: TryStream,
F: FnMut(St::Error) -> E,
impl<St, F, E> Stream for MapErr<St, F> where
St: TryStream,
F: FnMut(St::Error) -> E,
impl<St, Fut, F, T> Stream for TryFilterMap<St, Fut, F> where
St: TryStream,
Fut: TryFuture<Ok = Option<T>, Error = St::Error>,
F: FnMut(St::Ok) -> Fut,
impl<St, Fut, F, T> Stream for TryFilterMap<St, Fut, F> where
St: TryStream,
Fut: TryFuture<Ok = Option<T>, Error = St::Error>,
F: FnMut(St::Ok) -> Fut,
impl<St, Fut, F> Stream for TrySkipWhile<St, Fut, F> where
St: TryStream,
F: FnMut(&St::Ok) -> Fut,
Fut: TryFuture<Ok = bool, Error = St::Error>,
impl<St, Fut, F> Stream for TrySkipWhile<St, Fut, F> where
St: TryStream,
F: FnMut(&St::Ok) -> Fut,
Fut: TryFuture<Ok = bool, Error = St::Error>,
impl<St> Stream for TryBufferUnordered<St> where
St: TryStream,
St::Ok: TryFuture<Error = St::Error>,
impl<St> Stream for TryBufferUnordered<St> where
St: TryStream,
St::Ok: TryFuture<Error = St::Error>,
impl<S, E> Stream for SinkErrInto<S, E> where
S: Sink + Stream,
S::SinkError: Into<E>,
impl<S, E> Stream for SinkErrInto<S, E> where
S: Sink + Stream,
S::SinkError: Into<E>,
impl<S: Stream, F> Stream for SinkMapErr<S, F>
impl<S: Stream, F> Stream for SinkMapErr<S, F>
impl<S, U, Fut, F> Stream for With<S, U, Fut, F> where
S: Stream + Sink,
F: FnMut(U) -> Fut,
Fut: Future,
impl<S, U, Fut, F> Stream for With<S, U, Fut, F> where
S: Stream + Sink,
F: FnMut(U) -> Fut,
Fut: Future,
impl<S, U, St, F> Stream for WithFlatMap<S, U, St, F> where
S: Stream + Sink,
F: FnMut(U) -> St,
St: Stream<Item = Result<S::SinkItem, S::SinkError>>,
impl<S, U, St, F> Stream for WithFlatMap<S, U, St, F> where
S: Stream + Sink,
F: FnMut(U) -> St,
St: Stream<Item = Result<S::SinkItem, S::SinkError>>,
impl<S> Stream for Buffer<S> where
S: Sink + Stream,
impl<S> Stream for Buffer<S> where
S: Sink + Stream,
impl<St: Stream01> Stream for Compat01As03<St>
impl<St: Stream01> Stream for Compat01As03<St>