pub trait StreamExt: Stream {
Show 33 methods
// Provided methods
fn next(&mut self) -> Next<'_, Self> ⓘ
where Self: Unpin { ... }
fn map<T, F>(self, f: F) -> Map<Self, F>
where Self: Sized,
F: FnMut(Self::Item) -> T { ... }
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
where Self: Sized,
F: FnMut(Self::Item) -> Fut,
Fut: Future { ... }
fn chain<S2>(self, other: S2) -> Chain<Self, S2>
where Self: Sized,
S2: Stream<Item = Self::Item> { ... }
fn merge(self, other: Self) -> Merge<Self>
where Self: Sized { ... }
fn zip<S2>(self, other: S2) -> Zip<Self, S2>
where Self: Sized,
S2: Stream { ... }
fn filter<P>(self, predicate: P) -> Filter<Self, P>
where Self: Sized,
P: FnMut(&Self::Item) -> bool { ... }
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
where Self: Sized,
F: FnMut(Self::Item) -> Option<T> { ... }
fn take(self, n: usize) -> Take<Self>
where Self: Sized { ... }
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where Self: Sized,
P: FnMut(&Self::Item) -> bool { ... }
fn skip(self, n: usize) -> Skip<Self>
where Self: Sized { ... }
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where Self: Sized,
P: FnMut(&Self::Item) -> bool { ... }
fn enumerate(self) -> Enumerate<Self>
where Self: Sized { ... }
fn fuse(self) -> Fuse<Self>
where Self: Sized { ... }
fn inspect<F>(self, f: F) -> Inspect<Self, F>
where Self: Sized,
F: FnMut(&Self::Item) { ... }
fn buffered(self, n: usize) -> Buffered<Self>
where Self: Sized,
Self::Item: Future { ... }
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
where Self: Sized,
Self::Item: Future { ... }
fn collect<C>(self) -> Collect<Self, C> ⓘ
where Self: Sized,
C: Default + Extend<Self::Item> { ... }
fn chunks(self, size: usize) -> Chunks<Self>
where Self: Sized { ... }
fn ready_chunks(self, size: usize) -> ReadyChunks<Self>
where Self: Sized { ... }
fn fold<Acc, F>(self, init: Acc, f: F) -> Fold<Self, F, Acc> ⓘ
where Self: Sized,
F: FnMut(Acc, Self::Item) -> Acc { ... }
fn for_each<F>(self, f: F) -> ForEach<Self, F> ⓘ
where Self: Sized,
F: FnMut(Self::Item) { ... }
fn for_each_async<F, Fut>(self, f: F) -> ForEachAsync<Self, F, Fut> ⓘ
where Self: Sized,
F: FnMut(Self::Item) -> Fut,
Fut: Future<Output = ()> { ... }
fn count(self) -> Count<Self> ⓘ
where Self: Sized { ... }
fn any<P>(self, predicate: P) -> Any<Self, P> ⓘ
where Self: Sized,
P: FnMut(&Self::Item) -> bool { ... }
fn all<P>(self, predicate: P) -> All<Self, P> ⓘ
where Self: Sized,
P: FnMut(&Self::Item) -> bool { ... }
fn try_collect<T, E, C>(self) -> TryCollect<Self, C> ⓘ
where Self: Stream<Item = Result<T, E>> + Sized,
C: Default + Extend<T> { ... }
fn try_fold<T, E, Acc, F>(self, init: Acc, f: F) -> TryFold<Self, F, Acc> ⓘ
where Self: Stream<Item = Result<T, E>> + Sized,
F: FnMut(Acc, T) -> Result<Acc, E> { ... }
fn try_for_each<F, E>(self, f: F) -> TryForEach<Self, F> ⓘ
where Self: Sized,
F: FnMut(Self::Item) -> Result<(), E> { ... }
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where Self: Sized,
F: FnMut(&mut St, Self::Item) -> Option<B> { ... }
fn peekable(self) -> Peekable<Self>
where Self: Sized { ... }
fn throttle(self, period: Duration) -> Throttle<Self>
where Self: Sized { ... }
fn debounce(self, period: Duration) -> Debounce<Self>
where Self: Sized,
Self::Item: Unpin { ... }
}Expand description
Extension trait providing combinator methods for streams.
This trait is automatically implemented for all types that implement Stream.
Provided Methods§
Sourcefn next(&mut self) -> Next<'_, Self> ⓘwhere
Self: Unpin,
fn next(&mut self) -> Next<'_, Self> ⓘwhere
Self: Unpin,
Returns the next item from the stream.
Sourcefn zip<S2>(self, other: S2) -> Zip<Self, S2>
fn zip<S2>(self, other: S2) -> Zip<Self, S2>
Zips this stream with another stream, yielding pairs.
Sourcefn filter<P>(self, predicate: P) -> Filter<Self, P>
fn filter<P>(self, predicate: P) -> Filter<Self, P>
Yields only items that match the predicate.
Sourcefn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F>
Filters and transforms items in one step.
Sourcefn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
Takes items while the predicate is true.
Sourcefn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
Skips items while the predicate is true.
Sourcefn buffered(self, n: usize) -> Buffered<Self>
fn buffered(self, n: usize) -> Buffered<Self>
Buffers up to n futures, preserving output order.
Sourcefn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
Buffers up to n futures, yielding results as they complete.
Sourcefn chunks(self, size: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, size: usize) -> Chunks<Self>where
Self: Sized,
Collects items into fixed-size chunks.
Sourcefn ready_chunks(self, size: usize) -> ReadyChunks<Self>where
Self: Sized,
fn ready_chunks(self, size: usize) -> ReadyChunks<Self>where
Self: Sized,
Yields immediately available items up to a maximum chunk size.
Sourcefn fold<Acc, F>(self, init: Acc, f: F) -> Fold<Self, F, Acc> ⓘ
fn fold<Acc, F>(self, init: Acc, f: F) -> Fold<Self, F, Acc> ⓘ
Folds all items into a single value.
Sourcefn for_each_async<F, Fut>(self, f: F) -> ForEachAsync<Self, F, Fut> ⓘ
fn for_each_async<F, Fut>(self, f: F) -> ForEachAsync<Self, F, Fut> ⓘ
Executes an async closure for each item.
Sourcefn try_collect<T, E, C>(self) -> TryCollect<Self, C> ⓘ
fn try_collect<T, E, C>(self) -> TryCollect<Self, C> ⓘ
Collects items from a stream of Results, short-circuiting on error.
Sourcefn try_fold<T, E, Acc, F>(self, init: Acc, f: F) -> TryFold<Self, F, Acc> ⓘ
fn try_fold<T, E, Acc, F>(self, init: Acc, f: F) -> TryFold<Self, F, Acc> ⓘ
Folds a stream of Results, short-circuiting on error.
Sourcefn try_for_each<F, E>(self, f: F) -> TryForEach<Self, F> ⓘ
fn try_for_each<F, E>(self, f: F) -> TryForEach<Self, F> ⓘ
Executes a fallible closure for each item, short-circuiting on error.
Sourcefn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
Yields intermediate accumulator values, like Iterator::scan.
For each item, calls f(&mut state, item). If f returns
Some(value), the value is yielded. If f returns None,
the stream terminates.
Sourcefn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
Creates a peekable stream that supports looking at the next item without consuming it.
Sourcefn throttle(self, period: Duration) -> Throttle<Self>where
Self: Sized,
fn throttle(self, period: Duration) -> Throttle<Self>where
Self: Sized,
Rate-limits the stream to at most one item per period.
The first item passes through immediately. Subsequent items that arrive within the suppression window are dropped.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.