[−][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
type Item
Values yielded by the stream.
Required Methods
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> 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]
impl<'a, S: ?Sized + Stream + Unpin> Stream for &'a mut S
type Item = S::Item
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
[src]
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
impl<P> Stream for Pin<P> where
P: DerefMut,
P::Target: Stream,
[src]
impl<P> Stream for Pin<P> where
P: DerefMut,
P::Target: Stream,
type Item = <P::Target as Stream>::Item
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
[src]
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
impl<A, B> Stream for Either<A, B> where
A: Stream,
B: Stream<Item = A::Item>,
[src]
impl<A, B> Stream for Either<A, B> where
A: Stream,
B: Stream<Item = A::Item>,
type Item = A::Item
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<A::Item>>
[src]
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<A::Item>>
impl<S: ?Sized + Stream + Unpin> Stream for Box<S>
[src]
impl<S: ?Sized + Stream + Unpin> Stream for Box<S>
type Item = S::Item
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
[src]
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<Self::Item>>
impl<S: Stream> Stream for AssertUnwindSafe<S>
[src]
impl<S: Stream> Stream for AssertUnwindSafe<S>
type Item = S::Item
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<S::Item>>
[src]
fn poll_next(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Option<S::Item>>
impl<T: Unpin> Stream for VecDeque<T>
[src]
impl<T: Unpin> Stream for VecDeque<T>