#stream #operator #rx #tokio #future

tokio-stream-ext

Stream extension with new operators, this will grow over the time

2 releases

0.1.5 Aug 31, 2021
0.1.4 Aug 27, 2021

#6 in #rx

Download history 126/week @ 2024-06-05 185/week @ 2024-06-12 286/week @ 2024-06-19 220/week @ 2024-06-26 190/week @ 2024-07-03 197/week @ 2024-07-10 40/week @ 2024-07-17 37/week @ 2024-07-24 33/week @ 2024-07-31 53/week @ 2024-08-07 98/week @ 2024-08-14 92/week @ 2024-08-21 115/week @ 2024-08-28 123/week @ 2024-09-04 123/week @ 2024-09-11 166/week @ 2024-09-18

542 downloads per month

Custom license

13KB
309 lines

Tokio StreamExt [WIP]

Stream extension with new operators, this will grow over the time.

Feel free to contribute!

Todo

  • [] Better readme
  • [] RustDoc
  • [] Further operators

Operators

Debounce

Debounce a stream until it is sattled over a given duration.

ReceiverStream::new(self.input)
    .debounce(Duration::from_millis(80)),

distinct until changed

Filters events, similar to the last value.

The initial value is always emitted.

ReceiverStream::new(self.input)
    .distinct_until_changed(),

Switch Map

Reactive composing of streams.

switch_map(ReceiverStream::new(keyboard), move |value| {
    if value == 'k' {
        Some(ReceiverStream::new(gamepad))
    } else {
        Some(ReceiverStream::new(joystick))
    }
});

Combine Latest

Collects a value from all streams and switch to a live mode. Every new combination will be emitted from now on.

switch_map(ReceiverStream::new(keyboard), move |value| {
    if value == 'k' {
        Some(ReceiverStream::new(gamepad))
    } else {
        Some(ReceiverStream::new(joystick))
    }
});

Dependencies

~2.7–8MB
~64K SLoC