3 releases (breaking)

0.3.0 Jan 6, 2021
0.2.1 Nov 20, 2020
0.2.0 Nov 19, 2020
0.1.0 Feb 11, 2020

#439 in Unix APIs

Download history 1293/week @ 2024-03-14 1501/week @ 2024-03-21 1116/week @ 2024-03-28 1860/week @ 2024-04-04 4132/week @ 2024-04-11 5144/week @ 2024-04-18 5997/week @ 2024-04-25 5214/week @ 2024-05-02 2909/week @ 2024-05-09 4402/week @ 2024-05-16 5353/week @ 2024-05-23 2949/week @ 2024-05-30 4142/week @ 2024-06-06 3744/week @ 2024-06-13 5145/week @ 2024-06-20 3653/week @ 2024-06-27

17,090 downloads per month
Used in 12 crates (4 directly)

MIT/Apache

7KB
92 lines

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.

Dependencies

~2–14MB
~109K SLoC