4个版本
0.2.0 | 2021年3月8日 |
---|---|
0.1.2 | 2020年5月4日 |
0.1.1 | 2018年8月18日 |
0.1.0 | 2018年8月18日 |
#522 in 异步
1,646 每月下载量
用于 11 个crate (10直接)
14KB
268 行
readwrite
给定两个对象,其中一个实现了 std::io::Read
,另一个实现了 std::io::Write
,创建一个类似套接字的单一对象,该对象实现了 Read + Write
。注意,在等待从读取部分获取数据时,不能向其写入。
示例:生成虚拟套接字对。
fn main() {
extern crate pipe;
extern crate readwrite;
let (r1,w1) = pipe::pipe();
let (r2,w2) = pipe::pipe();
let (s1,s2) = (ReadWrite::new(r1,w2), ReadWrite::new(r2,w1));
}
还有一个将 tokio::io::AsyncRead
和 tokio::io::AsyncWrite
合并成一个 AsyncRead + AsyncWrite
的异步实现。要启用它,请启用非默认的 tokio
Cargo功能:同样,在 asyncstd
Cargo功能下,也有 futures::io::AsyncRead/AsyncWrite
版本。
[dependencies]
readwrite = {version="0.1.1", features=["tokio"]}
另请参阅
- duplexify - 用于 async-std 的替代实现
- 使用此crate的
0.1
版本支持旧tokio-core
。不支持tokio 0.1
。
依赖关系
~0–1.3MB
~22K SLoC