Skip to main content

BarterStreamExt

Trait BarterStreamExt 

Source
pub trait BarterStreamExt
where Self: Stream,
{ // Provided methods fn with_timeout<TimeoutHandler>( self, timeout_next_item: Duration, on_timeout: TimeoutHandler, ) -> impl Stream<Item = Self::Item> where Self: Stream + Sized, TimeoutHandler: FnOnce() + 'static { ... } fn with_index<I>(self, indexer: I) -> IndexedStream<Self, I> where Self: Stream<Item = I::Unindexed> + Sized, I: Indexer { ... } fn forward_by<A, B, FnPredicate, FnForward, FwdErr>( self, predicate: FnPredicate, forward: FnForward, ) -> ForwardBy<Self, FnPredicate, FnForward> where Self: Stream + Sized, FnPredicate: Fn(Self::Item) -> Either<A, B>, FnForward: FnMut(A) -> Result<(), FwdErr> { ... } fn forward_clone_by<FnPredicate, FnForward, FwdErr>( self, predicate: FnPredicate, forward: FnForward, ) -> ForwardCloneBy<Self, FnPredicate, FnForward> where Self: Stream + Sized, Self::Item: Clone, FnPredicate: FnMut(&Self::Item) -> bool, FnForward: FnMut(Self::Item) -> Result<(), FwdErr> { ... } }
Expand description

Stream extension trait.

Provided Methods§

Source

fn with_timeout<TimeoutHandler>( self, timeout_next_item: Duration, on_timeout: TimeoutHandler, ) -> impl Stream<Item = Self::Item>
where Self: Stream + Sized, TimeoutHandler: FnOnce() + 'static,

Add a “consecutive event timeout” to the Stream

Upon timeout, the Stream ends after executing the provided TimeoutHandler function.

Source

fn with_index<I>(self, indexer: I) -> IndexedStream<Self, I>
where Self: Stream<Item = I::Unindexed> + Sized, I: Indexer,

Indexes the Stream using the provided Indexer.

Source

fn forward_by<A, B, FnPredicate, FnForward, FwdErr>( self, predicate: FnPredicate, forward: FnForward, ) -> ForwardBy<Self, FnPredicate, FnForward>
where Self: Stream + Sized, FnPredicate: Fn(Self::Item) -> Either<A, B>, FnForward: FnMut(A) -> Result<(), FwdErr>,

Forward a subset of Stream::Items.

All items that the predicate returns as Left and forwarded, whilst Right items continue through the existing Stream.

Source

fn forward_clone_by<FnPredicate, FnForward, FwdErr>( self, predicate: FnPredicate, forward: FnForward, ) -> ForwardCloneBy<Self, FnPredicate, FnForward>
where Self: Stream + Sized, Self::Item: Clone, FnPredicate: FnMut(&Self::Item) -> bool, FnForward: FnMut(Self::Item) -> Result<(), FwdErr>,

Forward a clone of a subset of Stream::Items that match the predicate. The Stream still yields all items.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S> BarterStreamExt for S
where S: Stream,