#async-stream #async #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

#1387 in Asynchronous

Download history 1140/week @ 2024-07-23 1511/week @ 2024-07-30 1900/week @ 2024-08-06 962/week @ 2024-08-13 1315/week @ 2024-08-20 2199/week @ 2024-08-27 1594/week @ 2024-09-03 1397/week @ 2024-09-10 918/week @ 2024-09-17 1713/week @ 2024-09-24 1188/week @ 2024-10-01 1713/week @ 2024-10-08 2276/week @ 2024-10-15 1699/week @ 2024-10-22 1503/week @ 2024-10-29 1070/week @ 2024-11-05

6,941 downloads per month
Used in 11 crates (4 directly)

MIT license

11KB
267 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