4 个版本

0.1.3 2020年4月16日
0.1.2 2020年4月6日
0.1.1 2020年4月4日
0.1.0 2020年4月4日

#1560异步

Download history • Rust 包仓库 36/week @ 2024-03-30 • Rust 包仓库 15/week @ 2024-04-06 • Rust 包仓库 14/week @ 2024-04-13 • Rust 包仓库 19/week @ 2024-04-20 • Rust 包仓库 16/week @ 2024-04-27 • Rust 包仓库 15/week @ 2024-05-04 • Rust 包仓库 22/week @ 2024-05-11 • Rust 包仓库 29/week @ 2024-05-18 • Rust 包仓库 18/week @ 2024-05-25 • Rust 包仓库 22/week @ 2024-06-01 • Rust 包仓库 22/week @ 2024-06-08 • Rust 包仓库 17/week @ 2024-06-15 • Rust 包仓库 21/week @ 2024-06-22 • Rust 包仓库 20/week @ 2024-06-29 • Rust 包仓库 6/week @ 2024-07-06 • Rust 包仓库 6/week @ 2024-07-13 • Rust 包仓库

每月55次 下载
用于 4 个 crate(直接使用3个)

MIT 许可证

13KB
275

async-pipe-rs

crates.io Documentation MIT

使用 tokio.rs 创建异步管道读写器对。

文档

用法

首先将以下内容添加到您的 Cargo.toml 中

[dependencies]
async-pipe = "0.1"

示例

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));
}

贡献

您的 PR 和 stars 总是受欢迎的。


lib.rs:

使用 tokio.rs 创建异步管道读写器对。

示例

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());

依赖项

~3.5MB
~50K SLoC