StreamExt

Trait StreamExt 

Source
pub trait StreamExt: Stream {
Show 14 methods // 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> { ... } 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 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 + 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 { ... }
}
Expand description

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

Provided Methods§

Source

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

Source

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.

Source

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

A shorthand for encode::encode

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Create a Sendable boxed version of this Stream.

Source

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

Create a non-Sendable boxed version of this Stream.

Source

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

Shorthand for returning StreamEither::A

Source

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

Shorthand for returning StreamEither::B

Source

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

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

Source

fn buffered_weight_limited<I, E, Fut>( self, params: BufferedParams, ) -> WeightLimitedBufferedStream<Self, I, E>
where Self: Sized + Send + 'static + 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”.

Source

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

Implementors§

Source§

impl<T> StreamExt for T
where T: Stream,