Struct bee_runtime::shutdown_stream::ShutdownStream[][src]

pub struct ShutdownStream<S> { /* fields omitted */ }

A stream with a shutdown.

This type wraps a shutdown receiver and a stream to produce a new stream that ends when the shutdown receiver is triggered or when the stream ends.

Implementations

impl<S: Stream> ShutdownStream<Fuse<S>>[src]

pub fn new(shutdown: Receiver<()>, stream: S) -> Self[src]

Create a new ShutdownStream from a shutdown receiver and an unfused stream.

This method receives the stream to be wrapped and a oneshot::Receiver for the shutdown. Both the stream and the shutdown receiver are fused to avoid polling already completed futures.

pub fn from_fused(shutdown: Fuse<Receiver<()>>, stream: Fuse<S>) -> Self[src]

Create a new ShutdownStream from a fused shutdown receiver and a fused stream.

This method receives the fused stream to be wrapped and a fused oneshot::Receiver for the shutdown.

pub fn split(self) -> (Fuse<Receiver<()>>, Fuse<S>)[src]

Consume and split the ShutdownStream into its shutdown receiver and stream.

Trait Implementations

impl<S: Stream<Item = T> + FusedStream + Unpin, T> FusedStream for ShutdownStream<S>[src]

impl<S: Stream<Item = T> + FusedStream + Unpin, T> Stream for ShutdownStream<S>[src]

type Item = T

Values yielded by the stream.

fn poll_next(
    mut self: Pin<&mut Self>,
    cx: &mut Context<'_>
) -> Poll<Option<Self::Item>>
[src]

The shutdown receiver is polled first, if it is not ready, the stream is polled. This guarantees that checking for shutdown always happens first.

Auto Trait Implementations

impl<S> !RefUnwindSafe for ShutdownStream<S>[src]

impl<S> Send for ShutdownStream<S> where
    S: Send
[src]

impl<S> Sync for ShutdownStream<S> where
    S: Sync
[src]

impl<S> Unpin for ShutdownStream<S> where
    S: Unpin
[src]

impl<S> !UnwindSafe for ShutdownStream<S>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized