[][src]Trait futures_ext::StreamExt

pub trait StreamExt: Stream {
    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>
, { ... }
fn collect_no_consume(self) -> CollectNoConsume<Self>
    where
        Self: Sized
, { ... }
fn encode<Enc>(self, encoder: Enc) -> LayeredEncoder<Self, Enc>
    where
        Self: Sized,
        Enc: Encoder<Item = Self::Item>
, { ... }
fn enumerate(self) -> Enumerate<Self>
    where
        Self: Sized
, { ... }
fn return_remainder(
        self
    ) -> (ReturnRemainder<Self>, ConservativeReceiver<Self>)
    where
        Self: Sized
, { ... }
fn is_empty<'a>(
        self
    ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
    where
        Self: 'a + Send + Sized
, { ... }
fn not_empty<'a>(
        self
    ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
    where
        Self: 'a + Send + Sized
, { ... }
fn boxify(self) -> BoxStream<Self::Item, Self::Error>
    where
        Self: 'static + Send + Sized
, { ... }
fn boxify_nonsend(self) -> BoxStreamNonSend<Self::Item, Self::Error>
    where
        Self: 'static + Sized
, { ... }
fn left_stream<B>(self) -> StreamEither<Self, B>
    where
        Self: Sized
, { ... }
fn right_stream<A>(self) -> StreamEither<A, Self>
    where
        Self: Sized
, { ... }
fn whole_stream_timeout(self, duration: Duration) -> StreamWithTimeout<Self>
    where
        Self: Sized
, { ... }
fn batch(self, limit: usize) -> BatchStream<Self>
    where
        Self: Sized
, { ... }
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>
, { ... }
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

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>, 

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).

fn collect_no_consume(self) -> CollectNoConsume<Self> where
    Self: Sized

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

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

A shorthand for encode::encode

fn enumerate(self) -> Enumerate<Self> where
    Self: Sized

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

fn return_remainder(self) -> (ReturnRemainder<Self>, ConservativeReceiver<Self>) where
    Self: Sized

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.

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

Whether this stream is empty.

This will consume one element from the stream if returned.

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

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

This will consume one element from the stream if returned.

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

Create a Sendable boxed version of this Stream.

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

Create a non-Sendable boxed version of this Stream.

fn left_stream<B>(self) -> StreamEither<Self, B> where
    Self: Sized

Shorthand for returning StreamEither::A

fn right_stream<A>(self) -> StreamEither<A, Self> where
    Self: Sized

Shorthand for returning StreamEither::B

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

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

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

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

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>, 

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

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

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...