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§
Sourcefn streamfork<Out1, Out2, F, E>(
self,
out1: Out1,
out2: Out2,
pred: F,
) -> Forker<Self, Out1, Out2, F, E>
fn streamfork<Out1, Out2, F, E>( self, out1: Out1, out2: Out2, pred: F, ) -> Forker<Self, Out1, Out2, F, E>
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).
Sourcefn collect_no_consume(self) -> CollectNoConsume<Self>where
Self: Sized,
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.
Sourcefn encode<Enc>(self, encoder: Enc) -> LayeredEncoder<Self, Enc>
fn encode<Enc>(self, encoder: Enc) -> LayeredEncoder<Self, Enc>
A shorthand for encode::encode
Sourcefn enumerate(self) -> Enumerate<Self>where
Self: Sized,
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.
Sourcefn return_remainder(self) -> (ReturnRemainder<Self>, ConservativeReceiver<Self>)where
Self: Sized,
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.
Sourcefn is_empty<'a>(
self,
) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
fn is_empty<'a>( self, ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
Whether this stream is empty.
This will consume one element from the stream if returned.
Sourcefn not_empty<'a>(
self,
) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
fn not_empty<'a>( self, ) -> Box<dyn Future<Item = bool, Error = Self::Error> + Send + 'a>
Whether this stream is not empty (has at least one element).
This will consume one element from the stream if returned.
Sourcefn boxify(self) -> BoxStream<Self::Item, Self::Error>
fn boxify(self) -> BoxStream<Self::Item, Self::Error>
Create a Sendable boxed version of this Stream.
Sourcefn boxify_nonsend(self) -> BoxStreamNonSend<Self::Item, Self::Error>where
Self: 'static + Sized,
fn boxify_nonsend(self) -> BoxStreamNonSend<Self::Item, Self::Error>where
Self: 'static + Sized,
Create a non-Sendable boxed version of this Stream.
Sourcefn left_stream<B>(self) -> StreamEither<Self, B>where
Self: Sized,
fn left_stream<B>(self) -> StreamEither<Self, B>where
Self: Sized,
Shorthand for returning StreamEither::A
Sourcefn right_stream<A>(self) -> StreamEither<A, Self>where
Self: Sized,
fn right_stream<A>(self) -> StreamEither<A, Self>where
Self: Sized,
Shorthand for returning StreamEither::B
Sourcefn batch(self, limit: usize) -> BatchStream<Self>where
Self: Sized,
fn batch(self, limit: usize) -> BatchStream<Self>where
Self: Sized,
Similar to Stream::chunks, but returns earlier if futures::Async::NotReady was returned.
Sourcefn buffered_weight_limited<I, E, Fut>(
self,
params: BufferedParams,
) -> WeightLimitedBufferedStream<Self, I, E>
fn buffered_weight_limited<I, E, Fut>( self, params: BufferedParams, ) -> WeightLimitedBufferedStream<Self, I, E>
Like Stream::buffered call, but can also limit number of futures in a buffer by “weight”.