#reader-writer #writer #reader #pipe #async #future #tokio

async-pipe

Creates an asynchronous piped reader and writer pair using tokio.rs

4 releases

0.1.3 Apr 16, 2020
0.1.2 Apr 6, 2020
0.1.1 Apr 4, 2020
0.1.0 Apr 4, 2020

#1497 in Asynchronous

Download history 117/week @ 2024-11-16 68/week @ 2024-11-23 145/week @ 2024-11-30 128/week @ 2024-12-07 122/week @ 2024-12-14 8/week @ 2024-12-21 24/week @ 2024-12-28 31/week @ 2025-01-04 46/week @ 2025-01-11 135/week @ 2025-01-18 33/week @ 2025-01-25 24/week @ 2025-02-01 109/week @ 2025-02-08 114/week @ 2025-02-15 110/week @ 2025-02-22 39/week @ 2025-03-01

380 downloads per month
Used in 4 crates (3 directly)

MIT license

13KB
275 lines

async-pipe-rs

crates.io Documentation MIT

Creates an asynchronous piped reader and writer pair using tokio.rs.

Docs

Usage

First add this to your Cargo.toml:

[dependencies]
async-pipe = "0.1"

An example:

use async_pipe;
use tokio::prelude::*;

#[tokio::main]
async fn main() {
    let (mut w, mut r) = async_pipe::pipe();

    tokio::spawn(async move {
        w.write_all(b"hello world").await.unwrap();
    });

    let mut v = Vec::new();
    r.read_to_end(&mut v).await.unwrap();
    println!("Received: {:?}", String::from_utf8(v));
}

Contributing

Your PRs and stars are always welcome.


lib.rs:

Creates an asynchronous piped reader and writer pair using tokio.rs.

Examples

use async_pipe;
use tokio::prelude::*;

let (mut w, mut r) = async_pipe::pipe();
 
tokio::spawn(async move {
    w.write_all(b"hello world").await.unwrap();
});
 
let mut v = Vec::new();
r.read_to_end(&mut v).await.unwrap();

println!("Received: {:?}", String::from_utf8(v));

tokio::runtime::Runtime::new().unwrap().block_on(run());

Dependencies

~3.5MB
~53K SLoC