#async-stream #async #wrapper #transform

transform-stream

Lightweight async stream wrapper

5 unstable releases

0.3.0 Feb 1, 2023
0.2.0 Oct 13, 2021
0.1.2 Oct 22, 2020
0.1.1 Oct 4, 2020
0.1.0 Oct 3, 2020

#1421 in Asynchronous

Download history 879/week @ 2024-01-05 1117/week @ 2024-01-12 949/week @ 2024-01-19 1130/week @ 2024-01-26 1200/week @ 2024-02-02 1013/week @ 2024-02-09 1130/week @ 2024-02-16 810/week @ 2024-02-23 1236/week @ 2024-03-01 1445/week @ 2024-03-08 1519/week @ 2024-03-15 1203/week @ 2024-03-22 1409/week @ 2024-03-29 1442/week @ 2024-04-05 1961/week @ 2024-04-12 1454/week @ 2024-04-19

6,466 downloads per month
Used in 9 crates (4 directly)

MIT license

10KB
260 lines

transform-stream

Crates.io MIT licensed Docs

Lightweight async stream wrapper.

Documentation: https://docs.rs/transform-stream/

Inspired by https://github.com/tokio-rs/async-stream


lib.rs:

Lightweight async stream wrapper.

Inspired by https://github.com/tokio-rs/async-stream

Usage

use transform_stream::{try_stream, AsyncTryStream};
use futures_util::{pin_mut, StreamExt};
use std::io;

let stream: AsyncTryStream<Vec<u8>, io::Error, _> = try_stream!{
    yield_!(vec![b'1', b'2']);
    yield_!(vec![b'3', b'4']);
    Ok(())
};

futures_executor::block_on(async {
    pin_mut!(stream);
    assert_eq!(stream.next().await.unwrap().unwrap(), vec![b'1', b'2']);
    assert_eq!(stream.next().await.unwrap().unwrap(), vec![b'3', b'4']);
    assert!(stream.next().await.is_none());
});

Dependencies

~24KB