#operator #stream #reactive

stream-operators

a collection of selected rxjs operators for rust standard Stream

2 releases

0.1.1 Jan 11, 2023
0.1.0 Oct 21, 2022

#1296 in Asynchronous

MIT license

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

Operators supported by futures

Usage

See tests for each operator.

Dependencies

~2.1–3MB
~49K SLoC