Crates.io | tokio-anon-pipe |
lib.rs | tokio-anon-pipe |
version | 0.1.1 |
source | src |
created_at | 2021-06-25 08:48:51.907254 |
updated_at | 2021-06-27 03:02:15.867732 |
description | Asynchronous anonymous pipe for Windows. |
homepage | |
repository | https://github.com/yskszk63/tokio-anon-pipe |
max_upload_size | |
id | 414721 |
size | 30,811 |
Asynchronous anonymous pipe for Windows.
Note that we specifically do not use
CreatePipe
here because unfortunately the anonymous pipes returned do not support overlapped operations. Instead, we create a "hopefully unique" name and create a named pipe which has overlapped operations enabled.
x86_64-pc-windows-msvc
only
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let (mut r, mut w) = tokio_anon_pipe::anon_pipe().await?;
w.write_all(b"HELLO, WORLD!").await?;
let mut buf = [0; 16];
let len = r.read(&mut buf[..]).await?;
assert_eq!(&buf[..len], &b"HELLO, WORLD!"[..]);
Ok(())
}
License: MIT/Apache-2.0