tokio-fd

Crates.iotokio-fd
lib.rstokio-fd
version0.3.0
sourcesrc
created_at2020-02-11 05:07:01.081395
updated_at2021-01-06 14:20:55.512868
descriptionNon-blocking Read and Write a Linux File Descriptor
homepagehttps://github.com/nanpuyue/tokio-fd
repositoryhttps://github.com/nanpuyue/tokio-fd
max_upload_size
id207228
size16,178
南浦月 (nanpuyue)

documentation

README

Non-blocking Read and Write a Linux/Unix File Descriptor

Crates.io

Example

use std::convert::TryFrom;
use std::io::Result;

use tokio::prelude::*;
use tokio_fd::AsyncFd;

#[tokio::main]
async fn main() -> Result<()> {
    let mut stdin = AsyncFd::try_from(libc::STDIN_FILENO)?;
    let mut stdout = AsyncFd::try_from(libc::STDOUT_FILENO)?;
    let mut buf = vec![0; 1024];

    while let Ok(n) = stdin.read(&mut buf).await {
        stdout.write(&buf[..n]).await?;
    }
    Ok(())
}

License

This project is licensed under either of

at your option.

Commit count: 9

cargo fmt