#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

#4 in #operators

Download history 201/week @ 2024-11-16 137/week @ 2024-11-23 195/week @ 2024-11-30 197/week @ 2024-12-07 134/week @ 2024-12-14 20/week @ 2024-12-21 14/week @ 2024-12-28 75/week @ 2025-01-04 101/week @ 2025-01-11 355/week @ 2025-01-18 291/week @ 2025-01-25 233/week @ 2025-02-01 200/week @ 2025-02-08 196/week @ 2025-02-15 128/week @ 2025-02-22 321/week @ 2025-03-01

921 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–8.5MB
~64K SLoC