Trait completion_core::CompletionStream [−][src]
A Stream
where each value must be polled to completion.
All types that implement Stream
should also implement this.
A completion stream has three states: running, cancelling and exhausted. Streams initially
start out in the running state. To progress the running state, users will call poll_next
,
which either returns Poll::Pending
to continue the running state,
Poll::Ready
(
Some
)
to yield a value and continue the running state, or
Poll::Ready
(
None
)
to reach the exhausted state.
At any time during the running state, users may call poll_cancel
to initiate the cancelling
state. During this state, only poll_cancel
should be called, and it can return
Poll::Pending
to continue the cancelling state or Poll::Ready
(())
to reach the
exhausted state.
Once the exhausted state has been reached, either by poll_next
returning
Poll::Ready
(
None
)
or by poll_cancel
returning Poll::Ready
, neither
poll_next
nor poll_cancel
should be called again.
Associated Types
Loading content...Required methods
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> 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.
This function should only be called when the stream is in the running state.
Safety
Once this function has been called and the type does not also implement Stream
, the user
must not drop or forget the stream until it has returned Poll::Ready
or panicked.
Note that users may drop the stream in between finishing polling one item and starting to
poll the next.
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
Attempt to cancel the stream, registering the current task for wakeup if it has not finished cancelling yet.
This function should only be called when the stream is in the running state or in the
cancelling state. Once this function returns Poll::Ready
, the stream should be
considered exhausted and should not be polled again.
Safety
Once this function has been called and the type does not also implement Stream
, the user
must not drop or forget the stream until it has returned Poll::Ready
or panicked.
Note that users may drop the stream in between cancelling one item and starting to poll the
next.
Provided methods
fn size_hint(&self) -> (usize, Option<usize>)
[src]
Returns the bounds on the remaining length of the stream.
See Stream::size_hint
for more details.
Implementations on Foreign Types
impl<S: CompletionStream + Unpin + ?Sized> CompletionStream for &mut S
[src]
type Item = S::Item
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<S: CompletionStream + Unpin + ?Sized> CompletionStream for Box<S>
[src]
type Item = S::Item
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<P> CompletionStream for Pin<P> where
P: Unpin + DerefMut,
P::Target: CompletionStream,
[src]
P: Unpin + DerefMut,
P::Target: CompletionStream,
type Item = <P::Target as CompletionStream>::Item
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
unsafe fn poll_cancel(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<S: CompletionStream> CompletionStream for AssertUnwindSafe<S>
[src]
type Item = S::Item
unsafe fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>