#stream #rx #operators #future #tokio

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

#4 in #operators

Download history 196/week @ 2022-10-10 148/week @ 2022-10-17 149/week @ 2022-10-24 101/week @ 2022-10-31 90/week @ 2022-11-07 164/week @ 2022-11-14 202/week @ 2022-11-21 128/week @ 2022-11-28 114/week @ 2022-12-05 154/week @ 2022-12-12 98/week @ 2022-12-19 81/week @ 2022-12-26 202/week @ 2023-01-02 153/week @ 2023-01-09 46/week @ 2023-01-16 42/week @ 2023-01-23

443 downloads per month

Custom license

12KB
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.6–6.5MB
~101K SLoC