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

#468 in Unix APIs

Download history 4085/week @ 2024-06-09 4015/week @ 2024-06-16 4937/week @ 2024-06-23 3160/week @ 2024-06-30 3471/week @ 2024-07-07 4048/week @ 2024-07-14 4740/week @ 2024-07-21 4076/week @ 2024-07-28 3174/week @ 2024-08-04 2945/week @ 2024-08-11 4392/week @ 2024-08-18 4598/week @ 2024-08-25 3419/week @ 2024-09-01 2902/week @ 2024-09-08 3960/week @ 2024-09-15 4043/week @ 2024-09-22

14,505 downloads per month
Used in 13 crates (5 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.3–10MB
~92K SLoC