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.

```rust [tokio::main] async fn main() { use tokiostream::{self as stream, StreamExt}; use tokiostream_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.

bash 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.