#async #tokio #stream-ext

transform-stream

Lightweight async stream wrapper

6 releases

0.3.1 Jan 18, 2025
0.3.0 Feb 1, 2023
0.2.0 Oct 13, 2021
0.1.2 Oct 22, 2020

#219 in Asynchronous

Download history 895/week @ 2024-12-04 660/week @ 2024-12-11 624/week @ 2024-12-18 432/week @ 2024-12-25 988/week @ 2025-01-01 1359/week @ 2025-01-08 1397/week @ 2025-01-15 1277/week @ 2025-01-22 1347/week @ 2025-01-29 1252/week @ 2025-02-05 1244/week @ 2025-02-12 1714/week @ 2025-02-19 1633/week @ 2025-02-26 1794/week @ 2025-03-05 2496/week @ 2025-03-12 2013/week @ 2025-03-19

8,162 downloads per month
Used in 7 crates (4 directly)

MIT license

11KB
280 lines

transform-stream

Latest Version Documentation License

Lightweight async stream wrapper

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

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

Contributing


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