pub trait RS2StreamExt:
Stream
+ Sized
+ Unpin
+ Send
+ 'static {
Show 43 methods
// Provided methods
fn auto_backpressure_rs2(self) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn auto_backpressure_with_rs2(
self,
config: BackpressureConfig,
) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn map_rs2<U, F>(self, f: F) -> RS2Stream<U>
where F: FnMut(Self::Item) -> U + Send + 'static,
U: Send + 'static { ... }
fn map_parallel_rs2<O, F>(self, f: F) -> RS2Stream<O>
where F: Fn(Self::Item) -> O + Send + Sync + Clone + 'static,
Self::Item: Send + 'static,
O: Send + 'static { ... }
fn map_parallel_with_concurrency_rs2<O, F>(
self,
concurrency: usize,
f: F,
) -> RS2Stream<O>
where F: Fn(Self::Item) -> O + Send + Sync + Clone + 'static,
Self::Item: Send + 'static,
O: Send + 'static { ... }
fn filter_rs2<F>(self, f: F) -> RS2Stream<Self::Item>
where F: FnMut(&Self::Item) -> bool + Send + 'static,
Self::Item: Send + 'static { ... }
fn flat_map_rs2<U, St, F>(self, f: F) -> RS2Stream<U>
where F: FnMut(Self::Item) -> St + Send + 'static,
St: Stream<Item = U> + Send + 'static,
U: Send + 'static { ... }
fn eval_map_rs2<U, Fut, F>(self, f: F) -> RS2Stream<U>
where F: FnMut(Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = U> + Send + 'static,
U: Send + 'static { ... }
fn merge_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn zip_rs2<U>(self, other: RS2Stream<U>) -> RS2Stream<(Self::Item, U)>
where Self::Item: Send + 'static,
U: Send + 'static { ... }
fn zip_with_rs2<U, O, F>(self, other: RS2Stream<U>, f: F) -> RS2Stream<O>
where Self::Item: Send + 'static,
U: Send + 'static,
O: Send + 'static,
F: FnMut(Self::Item, U) -> O + Send + 'static { ... }
fn throttle_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn debounce_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn sample_rs2(self, interval: Duration) -> RS2Stream<Self::Item>
where Self::Item: Clone + Send + 'static { ... }
fn par_eval_map_rs2<U, Fut, F>(
self,
concurrency: usize,
f: F,
) -> RS2Stream<U>
where F: FnMut(Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = U> + Send + 'static,
U: Send + 'static,
Self::Item: Send + 'static { ... }
fn par_eval_map_unordered_rs2<U, Fut, F>(
self,
concurrency: usize,
f: F,
) -> RS2Stream<U>
where F: FnMut(Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = U> + Send + 'static,
U: Send + 'static,
Self::Item: Send + 'static { ... }
fn par_join_rs2<S, O>(self, concurrency: usize) -> RS2Stream<O>
where Self: Stream<Item = S>,
S: Stream<Item = O> + Send + 'static + Unpin,
O: Send + 'static { ... }
fn timeout_rs2(
self,
duration: Duration,
) -> RS2Stream<StreamResult<Self::Item>>
where Self::Item: Send + 'static { ... }
fn prefetch_rs2(self, prefetch_count: usize) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn distinct_until_changed_rs2(self) -> RS2Stream<Self::Item>
where Self::Item: Clone + Send + PartialEq + 'static { ... }
fn distinct_until_changed_by_rs2<F>(self, eq: F) -> RS2Stream<Self::Item>
where Self::Item: Clone + Send + 'static,
F: FnMut(&Self::Item, &Self::Item) -> bool + Send + 'static { ... }
fn interrupt_when_rs2<F>(self, signal: F) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static,
F: Future<Output = ()> + Send + 'static { ... }
fn take_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
where F: FnMut(&Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = bool> + Send + 'static,
Self::Item: Send + 'static { ... }
fn drop_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
where F: FnMut(&Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = bool> + Send + 'static,
Self::Item: Send + 'static { ... }
fn group_adjacent_by_rs2<K, F>(
self,
key_fn: F,
) -> RS2Stream<(K, Vec<Self::Item>)>
where Self::Item: Clone + Send + 'static,
K: Eq + Clone + Send + 'static,
F: FnMut(&Self::Item) -> K + Send + 'static { ... }
fn group_by_rs2<K, F>(self, key_fn: F) -> RS2Stream<(K, Vec<Self::Item>)>
where Self::Item: Clone + Send + 'static,
K: Eq + Clone + Send + 'static,
F: FnMut(&Self::Item) -> K + Send + 'static { ... }
fn fold_rs2<A, F, Fut>(self, init: A, f: F) -> impl Future<Output = A>
where F: FnMut(A, Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = A> + Send + 'static,
Self::Item: Send + 'static,
A: Send + 'static { ... }
fn scan_rs2<U, F>(self, init: U, f: F) -> RS2Stream<U>
where F: FnMut(U, Self::Item) -> U + Send + 'static,
Self::Item: Send + 'static,
U: Clone + Send + 'static { ... }
fn for_each_rs2<F, Fut>(self, f: F) -> impl Future<Output = ()>
where F: FnMut(Self::Item) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
Self::Item: Send + 'static { ... }
fn take_rs2(self, n: usize) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn drop_rs2(self, n: usize) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn skip_rs2(self, n: usize) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn either_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
where Self::Item: Send + 'static { ... }
fn collect_rs2<B>(self) -> impl Future<Output = B>
where B: Default + Extend<Self::Item> + Send + 'static,
Self::Item: Send + 'static { ... }
fn collect_with_config_rs2<B>(
self,
config: BufferConfig,
) -> impl Future<Output = B>
where B: Default + Extend<Self::Item> + Send + 'static,
Self::Item: Send + 'static { ... }
fn sliding_window_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
where Self::Item: Clone + Send + 'static { ... }
fn batch_process_rs2<U, F>(
self,
batch_size: usize,
processor: F,
) -> RS2Stream<U>
where F: FnMut(Vec<Self::Item>) -> Vec<U> + Send + 'static,
Self::Item: Send + 'static,
U: Send + 'static { ... }
fn with_metrics_rs2(
self,
name: String,
health_thresholds: HealthThresholds,
) -> (RS2Stream<Self::Item>, Arc<Mutex<StreamMetrics>>)
where Self::Item: Send + 'static { ... }
fn interleave_rs2<S>(self, streams: Vec<S>) -> RS2Stream<Self::Item>
where S: Stream<Item = Self::Item> + Send + 'static + Unpin,
Self::Item: Send + 'static { ... }
fn chunk_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
where Self::Item: Send + 'static { ... }
fn tick_rs<O>(self, period: Duration, item: O) -> RS2Stream<O>
where O: Clone + Send + 'static { ... }
fn bracket_rs<A, O, St, FAcq, FUse, FRel, R>(
self,
acquire: FAcq,
use_fn: FUse,
release: FRel,
) -> RS2Stream<O>
where FAcq: Future<Output = A> + Send + 'static,
FUse: FnOnce(A) -> St + Send + 'static,
St: Stream<Item = O> + Send + 'static,
FRel: FnOnce(A) -> R + Send + 'static,
R: Future<Output = ()> + Send + 'static,
O: Send + 'static,
A: Clone + Send + 'static { ... }
fn with_schema_validation_rs2<V, T>(
self,
validator: V,
) -> Pin<Box<dyn Stream<Item = T> + Send>>
where V: SchemaValidator + 'static,
T: DeserializeOwned + Serialize + Send + 'static,
Self: Stream<Item = T> + Send + 'static { ... }
}Expand description
Extension trait providing RS2-like combinators on Streams
Provided Methods§
Sourcefn auto_backpressure_rs2(self) -> RS2Stream<Self::Item>
fn auto_backpressure_rs2(self) -> RS2Stream<Self::Item>
Apply automatic backpressure with default configuration
Sourcefn auto_backpressure_with_rs2(
self,
config: BackpressureConfig,
) -> RS2Stream<Self::Item>
fn auto_backpressure_with_rs2( self, config: BackpressureConfig, ) -> RS2Stream<Self::Item>
Apply automatic backpressure with custom configuration
Sourcefn map_parallel_rs2<O, F>(self, f: F) -> RS2Stream<O>
fn map_parallel_rs2<O, F>(self, f: F) -> RS2Stream<O>
Transforms each element of the stream in parallel using all available CPU cores.
This method applies the given synchronous function to each element concurrently, automatically detecting the number of CPU cores and using that as the concurrency limit. Perfect for CPU-bound operations that benefit from parallelization.
§Arguments
f- A synchronous function that transforms each stream element. Must beSend + Sync + Clone.
§Returns
A new RS2Stream containing the transformed elements. Order may not be preserved.
§Performance
- Concurrency: Automatically uses
num_cpus::get()concurrent tasks - Best for: CPU-intensive computations (math, parsing, compression)
- Memory: Uses one task per CPU core, moderate memory overhead
- Backpressure: Inherits from underlying
par_eval_map_rs2
§When to Use
- ✅ CPU-bound work: Mathematical calculations, data parsing, compression
- ✅ Simple parallelization: Don’t want to think about optimal concurrency
- ✅ Balanced workloads: Each task takes roughly the same time
- ❌ I/O-bound work: Use
par_eval_map_rs2with higher concurrency instead - ❌ Memory-intensive: May overwhelm system with too many concurrent tasks
§See Also
- [
map_parallel_with_concurrency_rs2] - For custom concurrency control - [
par_eval_map_rs2] - For async functions and fine-tuned concurrency
Sourcefn map_parallel_with_concurrency_rs2<O, F>(
self,
concurrency: usize,
f: F,
) -> RS2Stream<O>
fn map_parallel_with_concurrency_rs2<O, F>( self, concurrency: usize, f: F, ) -> RS2Stream<O>
Transforms each element of the stream in parallel with custom concurrency control.
This method applies the given synchronous function to each element concurrently, using exactly the specified number of concurrent tasks. Ideal when you need precise control over resource usage or when the optimal concurrency differs from CPU count.
§Arguments
concurrency- Maximum number of concurrent tasks (must be > 0)f- A synchronous function that transforms each stream element. Must beSend + Sync + Clone.
§Returns
A new RS2Stream containing the transformed elements. Order may not be preserved.
§Performance
- Concurrency: Uses exactly
concurrencyconcurrent tasks - Best for: I/O-bound operations, memory-constrained environments, fine-tuning
- Memory: Scales with concurrency parameter
- Backpressure: Inherits from underlying
par_eval_map_rs2
§Concurrency Guidelines
| Workload Type | Recommended Concurrency | Reasoning |
|---|---|---|
| CPU-bound | num_cpus::get() | Match CPU cores |
| I/O-bound | 50-200 | Network can handle many concurrent requests |
| Memory-heavy | 1-4 | Prevent out-of-memory errors |
| Database queries | 10-50 | Respect connection pool limits |
| File I/O | 4-16 | Balance throughput vs file handle limits |
§When to Use
- ✅ I/O-bound operations: Network requests, file operations, database queries
- ✅ Resource constraints: Limited memory, connection pools, rate limits
- ✅ Performance tuning: Benchmarked optimal concurrency for your workload
- ✅ Mixed workloads: Some tasks much slower/faster than others
- ❌ Simple CPU-bound work: Use
map_parallel_rs2for automatic optimization
§Panics
This function will panic if concurrency is 0. Always use a positive value.
§See Also
- [
map_parallel_rs2] - For automatic concurrency based on CPU cores - [
par_eval_map_rs2] - For async functions with the same concurrency control
Sourcefn filter_rs2<F>(self, f: F) -> RS2Stream<Self::Item>
fn filter_rs2<F>(self, f: F) -> RS2Stream<Self::Item>
Filter elements of the rs2_stream with a predicate
Sourcefn flat_map_rs2<U, St, F>(self, f: F) -> RS2Stream<U>
fn flat_map_rs2<U, St, F>(self, f: F) -> RS2Stream<U>
Flat map elements of the rs2_stream with a function that returns a rs2_stream
Sourcefn eval_map_rs2<U, Fut, F>(self, f: F) -> RS2Stream<U>
fn eval_map_rs2<U, Fut, F>(self, f: F) -> RS2Stream<U>
Map elements of the rs2_stream with an async function
Sourcefn merge_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
fn merge_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
Merge this rs2_stream with another rs2_stream
Sourcefn zip_rs2<U>(self, other: RS2Stream<U>) -> RS2Stream<(Self::Item, U)>
fn zip_rs2<U>(self, other: RS2Stream<U>) -> RS2Stream<(Self::Item, U)>
Zip this rs2_stream with another rs2_stream
Sourcefn zip_with_rs2<U, O, F>(self, other: RS2Stream<U>, f: F) -> RS2Stream<O>
fn zip_with_rs2<U, O, F>(self, other: RS2Stream<U>, f: F) -> RS2Stream<O>
Zip this rs2_stream with another rs2_stream, applying a function to each pair
Sourcefn throttle_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
fn throttle_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
Throttle this rs2_stream to emit at most one element per duration
Sourcefn debounce_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
fn debounce_rs2(self, duration: Duration) -> RS2Stream<Self::Item>
Debounce this rs2_stream, only emitting an element after a specified quiet period has passed without receiving another element
Sourcefn sample_rs2(self, interval: Duration) -> RS2Stream<Self::Item>
fn sample_rs2(self, interval: Duration) -> RS2Stream<Self::Item>
Sample this rs2_stream at regular intervals, emitting the most recent value
This combinator samples the most recent value from a rs2_stream at a regular interval. It only emits a value if at least one new value has arrived since the last emission. If no new value has arrived during an interval, that interval is skipped.
Sourcefn par_eval_map_rs2<U, Fut, F>(self, concurrency: usize, f: F) -> RS2Stream<U>
fn par_eval_map_rs2<U, Fut, F>(self, concurrency: usize, f: F) -> RS2Stream<U>
Process elements in parallel with bounded concurrency, preserving order
§Use when: par_eval_map_rs2
- Already have async functions**
- Need custom concurrency control**
- Want maximum control/performance**
Sourcefn par_eval_map_unordered_rs2<U, Fut, F>(
self,
concurrency: usize,
f: F,
) -> RS2Stream<U>
fn par_eval_map_unordered_rs2<U, Fut, F>( self, concurrency: usize, f: F, ) -> RS2Stream<U>
Process elements in parallel with bounded concurrency, without preserving order
Sourcefn par_join_rs2<S, O>(self, concurrency: usize) -> RS2Stream<O>
fn par_join_rs2<S, O>(self, concurrency: usize) -> RS2Stream<O>
Run multiple streams concurrently and combine their outputs
This combinator takes a rs2_stream of streams and a concurrency limit, and runs up to n inner streams concurrently. It emits all elements from the inner streams, and starts new inner streams as others complete.
Sourcefn timeout_rs2(self, duration: Duration) -> RS2Stream<StreamResult<Self::Item>>
fn timeout_rs2(self, duration: Duration) -> RS2Stream<StreamResult<Self::Item>>
Add timeout to rs2_stream operations
Sourcefn prefetch_rs2(self, prefetch_count: usize) -> RS2Stream<Self::Item>
fn prefetch_rs2(self, prefetch_count: usize) -> RS2Stream<Self::Item>
Prefetch a specified number of elements ahead of consumption
This can improve performance by starting to process the next elements before they’re actually needed.
Sourcefn distinct_until_changed_rs2(self) -> RS2Stream<Self::Item>
fn distinct_until_changed_rs2(self) -> RS2Stream<Self::Item>
Filter out consecutive duplicate elements from this rs2_stream
This combinator only emits elements that are different from the previous element.
It uses the default equality operator (==) to compare elements.
The first element is always emitted.
Sourcefn distinct_until_changed_by_rs2<F>(self, eq: F) -> RS2Stream<Self::Item>
fn distinct_until_changed_by_rs2<F>(self, eq: F) -> RS2Stream<Self::Item>
Filter out consecutive duplicate elements from this rs2_stream using a custom equality function
This combinator only emits elements that are different from the previous element. It uses the provided equality function to compare elements. The first element is always emitted.
Sourcefn interrupt_when_rs2<F>(self, signal: F) -> RS2Stream<Self::Item>
fn interrupt_when_rs2<F>(self, signal: F) -> RS2Stream<Self::Item>
Interrupt this rs2_stream when a signal is received
This combinator stops processing the rs2_stream when the signal future completes. Resources are properly cleaned up when the rs2_stream is interrupted.
Sourcefn take_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
fn take_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
Take elements from this rs2_stream while a predicate returns true
This combinator yields elements from the stream as long as the predicate returns true. It stops (and does not yield) the first element where the predicate returns false.
Sourcefn drop_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
fn drop_while_rs2<F, Fut>(self, predicate: F) -> RS2Stream<Self::Item>
Skip elements from this rs2_stream while a predicate returns true
This combinator skips elements from the stream as long as the predicate returns true. Once the predicate returns false, it yields that element and all remaining elements.
Sourcefn group_adjacent_by_rs2<K, F>(
self,
key_fn: F,
) -> RS2Stream<(K, Vec<Self::Item>)>
fn group_adjacent_by_rs2<K, F>( self, key_fn: F, ) -> RS2Stream<(K, Vec<Self::Item>)>
Group adjacent elements that share a common key
This combinator groups consecutive elements that produce the same key. It emits groups as they complete (when the key changes or the rs2_stream ends). Each emitted item is a tuple containing the key and a vector of elements.
Sourcefn group_by_rs2<K, F>(self, key_fn: F) -> RS2Stream<(K, Vec<Self::Item>)>
fn group_by_rs2<K, F>(self, key_fn: F) -> RS2Stream<(K, Vec<Self::Item>)>
Group consecutive elements that share a common key
This combinator groups consecutive elements that produce the same key. It emits groups as they complete (when the key changes or the rs2_stream ends). Each emitted item is a tuple containing the key and a vector of elements.
Sourcefn fold_rs2<A, F, Fut>(self, init: A, f: F) -> impl Future<Output = A>
fn fold_rs2<A, F, Fut>(self, init: A, f: F) -> impl Future<Output = A>
Fold operation that accumulates a value over a stream
This combinator applies a function to each element in the stream, accumulating a single result. It returns a Future that resolves to the final accumulated value.
Sourcefn scan_rs2<U, F>(self, init: U, f: F) -> RS2Stream<U>
fn scan_rs2<U, F>(self, init: U, f: F) -> RS2Stream<U>
Scan operation that applies a function to each element and emits intermediate accumulated values
This combinator is similar to fold but emits each intermediate accumulated value. It applies a function to each element in the stream, accumulating a result and yielding each intermediate accumulated value.
Sourcefn for_each_rs2<F, Fut>(self, f: F) -> impl Future<Output = ()>
fn for_each_rs2<F, Fut>(self, f: F) -> impl Future<Output = ()>
Apply a function to each element in the stream
This combinator applies a function to each element in the stream without accumulating a result. It returns a Future that completes when the stream is exhausted.
Sourcefn take_rs2(self, n: usize) -> RS2Stream<Self::Item>
fn take_rs2(self, n: usize) -> RS2Stream<Self::Item>
Take the first n elements from the stream
This combinator yields the first n elements from the stream and then stops.
Sourcefn drop_rs2(self, n: usize) -> RS2Stream<Self::Item>
fn drop_rs2(self, n: usize) -> RS2Stream<Self::Item>
Drop the first n elements from the stream
This combinator skips the first n elements from the stream and yields all remaining elements.
Sourcefn skip_rs2(self, n: usize) -> RS2Stream<Self::Item>
fn skip_rs2(self, n: usize) -> RS2Stream<Self::Item>
Skip the first n elements from the stream
This combinator skips the first n elements from the stream and yields all remaining elements.
Sourcefn either_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
fn either_rs2(self, other: RS2Stream<Self::Item>) -> RS2Stream<Self::Item>
Select between this rs2_stream and another rs2_stream based on which one produces a value first
This combinator emits values from whichever rs2_stream produces a value first. Once a value is received from one rs2_stream, the other rs2_stream is cancelled. If either rs2_stream completes (returns None), the combinator switches to the other rs2_stream exclusively.
Sourcefn collect_rs2<B>(self) -> impl Future<Output = B>
fn collect_rs2<B>(self) -> impl Future<Output = B>
Collect all items from the stream into a collection
This combinator collects all items from the stream into a collection of type B. It returns a Future that resolves to the collection.
§Examples
use rs2_stream::rs2::*;
use futures_util::stream::StreamExt;
let stream = from_iter(vec![1, 2, 3, 4, 5]);
let result = stream.collect_rs2::<Vec<_>>().await;
assert_eq!(result, vec![1, 2, 3, 4, 5]);Sourcefn collect_with_config_rs2<B>(
self,
config: BufferConfig,
) -> impl Future<Output = B>
fn collect_with_config_rs2<B>( self, config: BufferConfig, ) -> impl Future<Output = B>
Collect all items from the stream into a collection with custom buffer configuration
This combinator collects all items from the stream into a collection of type B. It returns a Future that resolves to the collection. The buffer configuration allows for optimized memory allocation and growth strategies.
Sourcefn sliding_window_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
fn sliding_window_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
Create a sliding window of elements from the stream
This combinator creates a sliding window of the specified size over the stream. It yields a vector of items for each window position.
Sourcefn batch_process_rs2<U, F>(
self,
batch_size: usize,
processor: F,
) -> RS2Stream<U>
fn batch_process_rs2<U, F>( self, batch_size: usize, processor: F, ) -> RS2Stream<U>
Process items in batches for better throughput
This combinator processes items in batches of the specified size, applying the processor function to each batch.
Sourcefn with_metrics_rs2(
self,
name: String,
health_thresholds: HealthThresholds,
) -> (RS2Stream<Self::Item>, Arc<Mutex<StreamMetrics>>)
fn with_metrics_rs2( self, name: String, health_thresholds: HealthThresholds, ) -> (RS2Stream<Self::Item>, Arc<Mutex<StreamMetrics>>)
Collect metrics while processing the stream
This combinator collects metrics while processing the stream, returning both the stream and the metrics.
Sourcefn interleave_rs2<S>(self, streams: Vec<S>) -> RS2Stream<Self::Item>
fn interleave_rs2<S>(self, streams: Vec<S>) -> RS2Stream<Self::Item>
Interleave multiple streams in a round-robin fashion
This combinator takes a vector of streams and interleaves their elements in a round-robin fashion.
Sourcefn chunk_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
fn chunk_rs2(self, size: usize) -> RS2Stream<Vec<Self::Item>>
Chunk the stream into vectors of the specified size
This combinator collects elements from the stream into vectors of the specified size. If the stream ends before a chunk is filled, the final chunk may contain fewer elements.
Sourcefn tick_rs<O>(self, period: Duration, item: O) -> RS2Stream<O>
fn tick_rs<O>(self, period: Duration, item: O) -> RS2Stream<O>
Create a stream that emits values at a fixed rate
This combinator creates a stream that emits the provided item at a fixed rate.
Sourcefn bracket_rs<A, O, St, FAcq, FUse, FRel, R>(
self,
acquire: FAcq,
use_fn: FUse,
release: FRel,
) -> RS2Stream<O>
fn bracket_rs<A, O, St, FAcq, FUse, FRel, R>( self, acquire: FAcq, use_fn: FUse, release: FRel, ) -> RS2Stream<O>
Bracket for resource management
This combinator ensures that a resource is properly released after use. It takes three parameters:
- A future that acquires a resource
- A function that uses the resource and returns a stream
- A function that releases the resource
fn with_schema_validation_rs2<V, T>(
self,
validator: V,
) -> Pin<Box<dyn Stream<Item = T> + Send>>where
V: SchemaValidator + 'static,
T: DeserializeOwned + Serialize + Send + 'static,
Self: Stream<Item = T> + Send + 'static,
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.