tokio-stream-extra

Crates.iotokio-stream-extra
lib.rstokio-stream-extra
version0.0.3
sourcesrc
created_at2022-12-08 17:03:24.738297
updated_at2022-12-09 08:50:25.559876
descriptionA crate for stream extensions.
homepage
repositoryhttps://github.com/veminovici/tokio-stream-extra
max_upload_size
id732701
size16,819
VLAD EMINOVICI (veminovici)

documentation

https://docs.rs/tokio-stream-extra

README

Tokio-Stream-Extra

A crate that extends the Stream trait. For more details about streams please check the tokio-stream crate as well as StreamExt trait documentation.

Rust Crates.io Crates.io Crates.io

Examples

Split

Splits this stream's items at a separation item. The separation item is determined by provided closure. A stream of vectors of item type will be returned, which will yield elements until the closure returns None.

[tokio::main]
async fn main() {
    use tokio_stream::{self as stream, StreamExt};
    use tokio_stream_extra::StreamExtra;

    let stream = stream::iter(vec![1,2,0,3,4,0]);
    let mut stream = stream.split(|x| x == &0);

    assert_eq!(stream.next().await, Some(vec![1,2]));
    assert_eq!(stream.next().await, Some(vec![3,4]));

Tests

Test Coverage

To get the test coverage, I use the grcov. See the instructions steps.

export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="./coverage/lib-%p-%m.profraw"
cargo build
cargo test
grcov ./coverage -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
open ./target/debug/coverage/index.html

Property Based Testing

The library is using property based testing. It uses the quickcheck crate.

About

Code designed and written on the beautiful island of Saaremaa, Estonia.

Commit count: 5

cargo fmt