#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

#1407 in Asynchronous

Download history 899/week @ 2023-12-06 800/week @ 2023-12-13 407/week @ 2023-12-20 249/week @ 2023-12-27 806/week @ 2024-01-03 889/week @ 2024-01-10 1166/week @ 2024-01-17 1035/week @ 2024-01-24 1194/week @ 2024-01-31 840/week @ 2024-02-07 1318/week @ 2024-02-14 893/week @ 2024-02-21 1166/week @ 2024-02-28 1216/week @ 2024-03-06 1505/week @ 2024-03-13 1137/week @ 2024-03-20

5,090 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

~25KB