[][src]Trait futures_ext::StreamExt

pub trait StreamExt: Stream {
    pub fn streamfork<Out1, Out2, F, E>(
        self,
        out1: Out1,
        out2: Out2,
        pred: F
    ) -> Forker<Self, Out1, Out2, F, E>
    where
        Self: Sized,
        Out1: Sink<SinkItem = Self::Item>,
        Out2: Sink<SinkItem = Self::Item, SinkError = Out1::SinkError>,
        F: FnMut(&Self::Item) -> Result<bool, E>,
        E: From<Self::Error> + From<Out1::SinkError> + From<Out2::SinkError>
, { ... }
pub fn collect_no_consume(self) -> CollectNoConsume<Self>
    where
        Self: Sized
, { ... }
pub fn encode<Enc>(self, encoder: Enc) -> LayeredEncoder<Self, Enc>
    where
        Self: Sized,
        Enc: Encoder<Item = Self::Item>
, { ... }
pub fn enumerate(self) -> Enumerate<Self>
    where
        Self: Sized
, { ... }
pub fn return_remainder(
        self
    ) -> (ReturnRemainder<Self>, ConservativeReceiver<Self>)
    where
        Self: Sized
, { ... }
pub fn is_empty<'a>(
        self
    ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
    where
        Self: 'a + Send + Sized
, { ... }
pub fn not_empty<'a>(
        self
    ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
    where
        Self: 'a + Send + Sized
, { ... }
pub fn boxify(self) -> BoxStream<Self::Item, Self::Error>
    where
        Self: 'static + Send + Sized
, { ... }
pub fn boxify_nonsend(self) -> BoxStreamNonSend<Self::Item, Self::Error>
    where
        Self: 'static + Sized
, { ... }
pub fn left_stream<B>(self) -> StreamEither<Self, B>
    where
        Self: Sized
, { ... }
pub fn right_stream<A>(self) -> StreamEither<A, Self>
    where
        Self: Sized
, { ... }
pub fn whole_stream_timeout(
        self,
        duration: Duration
    ) -> StreamWithTimeout<Self>
    where
        Self: Sized
, { ... }
pub fn batch(self, limit: usize) -> BatchStream<Self>
    where
        Self: Sized
, { ... }
pub fn buffered_weight_limited<I, E, Fut>(
        self,
        params: BufferedParams
    ) -> WeightLimitedBufferedStream<Self, I, E>
    where
        Self: Sized + Send + 'static,
        Self: Stream<Item = (Fut, u64), Error = E>,
        Fut: Future<Item = I, Error = E>
, { ... }
pub fn collect_to<C: Default + Extend<Self::Item>>(
        self
    ) -> CollectTo<Self, C>
    where
        Self: Sized
, { ... } }

A trait implemented by default for all Streams which extends the standard functionality.

Provided methods

pub fn streamfork<Out1, Out2, F, E>(
    self,
    out1: Out1,
    out2: Out2,
    pred: F
) -> Forker<Self, Out1, Out2, F, E> where
    Self: Sized,
    Out1: Sink<SinkItem = Self::Item>,
    Out2: Sink<SinkItem = Self::Item, SinkError = Out1::SinkError>,
    F: FnMut(&Self::Item) -> Result<bool, E>,
    E: From<Self::Error> + From<Out1::SinkError> + From<Out2::SinkError>, 
[src]

Fork elements in a stream out to two sinks, depending on a predicate

If the predicate returns false, send the item to out1, otherwise to out2. streamfork() acts in a similar manner to forward() in that it keeps operating until the input stream ends, and then returns everything in the resulting Future.

The predicate returns a Result so that it can fail (if there's a malformed input that can't be assigned to either output).

pub fn collect_no_consume(self) -> CollectNoConsume<Self> where
    Self: Sized
[src]

Returns a future that yields a (Vec<<Self>::Item>, Self), where the vector is a collections of all elements yielded by the Stream.

pub fn encode<Enc>(self, encoder: Enc) -> LayeredEncoder<Self, Enc> where
    Self: Sized,
    Enc: Encoder<Item = Self::Item>, 
[src]

A shorthand for encode::encode

pub fn enumerate(self) -> Enumerate<Self> where
    Self: Sized
[src]

Similar to std::iter::Iterator::enumerate, returns a Stream that yields (usize, Self::Item) where the first element of tuple is the iteration count.

pub fn return_remainder(
    self
) -> (ReturnRemainder<Self>, ConservativeReceiver<Self>) where
    Self: Sized
[src]

Creates a stream wrapper and a future. The future will resolve into the wrapped stream when the stream wrapper returns None. It uses ConservativeReceiver to ensure that deadlocks are easily caught when one tries to poll on the receiver before consuming the stream.

pub fn is_empty<'a>(
    self
) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a> where
    Self: 'a + Send + Sized
[src]

Whether this stream is empty.

This will consume one element from the stream if returned.

pub fn not_empty<'a>(
    self
) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a> where
    Self: 'a + Send + Sized
[src]

Whether this stream is not empty (has at least one element).

This will consume one element from the stream if returned.

pub fn boxify(self) -> BoxStream<Self::Item, Self::Error> where
    Self: 'static + Send + Sized
[src]

Create a Sendable boxed version of this Stream.

pub fn boxify_nonsend(self) -> BoxStreamNonSend<Self::Item, Self::Error> where
    Self: 'static + Sized
[src]

Create a non-Sendable boxed version of this Stream.

pub fn left_stream<B>(self) -> StreamEither<Self, B> where
    Self: Sized
[src]

Shorthand for returning StreamEither::A

pub fn right_stream<A>(self) -> StreamEither<A, Self> where
    Self: Sized
[src]

Shorthand for returning StreamEither::B

pub fn whole_stream_timeout(self, duration: Duration) -> StreamWithTimeout<Self> where
    Self: Sized
[src]

It's different from tokio::timer::Timeout in that it sets a timeout on the whole Stream, not just on a single Stream item

pub fn batch(self, limit: usize) -> BatchStream<Self> where
    Self: Sized
[src]

Similar to Stream::chunks, but returns earlier if futures::Async::NotReady was returned.

pub fn buffered_weight_limited<I, E, Fut>(
    self,
    params: BufferedParams
) -> WeightLimitedBufferedStream<Self, I, E> where
    Self: Sized + Send + 'static,
    Self: Stream<Item = (Fut, u64), Error = E>,
    Fut: Future<Item = I, Error = E>, 
[src]

Like Stream::buffered call, but can also limit number of futures in a buffer by "weight".

pub fn collect_to<C: Default + Extend<Self::Item>>(self) -> CollectTo<Self, C> where
    Self: Sized
[src]

Returns a Future that yields a collection C containing all Self::Item yielded by the stream

Loading content...

Implementors

impl<T> StreamExt for T where
    T: Stream
[src]

Loading content...