2 releases
0.1.1 | Jan 11, 2023 |
---|---|
0.1.0 | Oct 21, 2022 |
#1211 in Asynchronous
20KB
391 lines
Stream Operators
This is a collection of selected rxjs operators for rust standard Stream. Though the operators are coming from the ReactiveX world, I'm not trying to reinvent the observable ecosystem for rust. If you need that, you could use rxrust. For this repom I'm just trying to provide a set of stream operators which could be used for Stream.
Supported Operators
- debounce_time
- distinct_until_changed
- distinct
- pluck: Maps each source value to its specified nested property.
- find: Emits the first value that matches the condition.
- find_index: Emits the index of the first value that matches the condition.
- group_by: Groups the items emitted by an Observable according to a specified criterion, and emits these grouped items as GroupedObservables, one GroupedObservable per group.
- pairwise: Emits the previous and current value as a two-element array.
- partition: Splits the source Observable into two, one with values that satisfy a predicate, and another with values that don't satisfy the predicate.
- sample_time: Samples the source Observable at periodic time intervals, emitting the most recent value emitted by the source Observable since the previous sampling, unless the source has not emitted anything since the previous sampling.
- sequence_equal: Determines whether two Observables emit the same sequence of items.
- throttle_time: Emits a value from the source Observable, then ignores subsequent source values for a duration determined by another Observable, then repeats this process.
Operators supported by tokio-stream
- every: see tokio-stream::StreamExt::all
- filter: see tokio-stream filter
- map: see tokio-stream map
- reduce: see tokio-stream fold
- concat_with: see tokio-stream chain
- buffer_time: see tokio-stream chunks_timeout
- buffer_count: see tokio-stream chunks_timeout
- merge_with: see tokio-stream merge
- skip: see tokio-stream skip
- skip_while: see tokio-stream skip_while
- take: see tokio-stream take
- take_while: see tokio-stream take_while
- timeout: see tokio-stream timeout
- delay: see tokio-stream throttle
Operators supported by futures
- count: see futures::StreamExt::count
- flat_map: see futures::StreamExt::flat_map
- repeat: see futures::StreamExt::cycle
- scan: see futures scan
- zip_with: see futures zip
Usage
See tests for each operator.
Dependencies
~2.2–8MB
~50K SLoC