#io-stream #io #async-io #async #merge #async-read #async-write

merge-io

Merge two separate AsyncRead and AsyncWrite objects into a single I/O stream

5 unstable releases

0.3.0 Dec 13, 2019
0.2.0 Sep 30, 2019
0.1.2 Aug 30, 2019
0.1.1 Aug 3, 2019
0.1.0 Jul 28, 2019

#2082 in Asynchronous

Download history 39/week @ 2024-09-12 60/week @ 2024-09-19 41/week @ 2024-09-26 29/week @ 2024-10-03 63/week @ 2024-10-10 14/week @ 2024-10-17 5/week @ 2024-10-24 19/week @ 2024-10-31 12/week @ 2024-11-07 26/week @ 2024-11-14 22/week @ 2024-11-21 23/week @ 2024-11-28 25/week @ 2024-12-05 55/week @ 2024-12-12 12/week @ 2024-12-19 32/week @ 2024-12-26

127 downloads per month
Used in 3 crates

MIT license

7KB
80 lines

merge-io

Build Status Crates.io Documentation

Merge two separate AsyncRead and AsyncWrite objects into a single I/O stream.

Documentation


lib.rs:

Merge two separate AsyncRead and AsyncWrite objects into a single I/O stream.

Examples

use merge_io::MergeIO;
use futures::io::Cursor;
use futures::{AsyncReadExt, AsyncWriteExt};

// Prepare `reader` to read data from...
let reader = Cursor::new(vec![1, 2, 3, 4]);

// ... and `writer` to read data to.
let writer: Vec<u8> = vec![];

// Merge `reader` and `writer` into a single I/O stream.
let mut stream = MergeIO::new(reader, writer);

// Read data from stream.
let mut read_buf = Vec::<u8>::with_capacity(1024);
stream.read_to_end(&mut read_buf).await?;

// We got what was in the `reader`!
assert_eq!(&read_buf, &[1, 2, 3, 4]);

// Write data to stream.
stream.write_all(&[10, 20, 30, 40]).await?;

// `writer` now contains what we wrote!
assert_eq!(stream.writer(), &[10, 20, 30, 40]);

Dependencies

~19KB