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

#419 in Unix APIs

Download history 4903/week @ 2024-07-20 4065/week @ 2024-07-27 3246/week @ 2024-08-03 2897/week @ 2024-08-10 4407/week @ 2024-08-17 4531/week @ 2024-08-24 3419/week @ 2024-08-31 2923/week @ 2024-09-07 3967/week @ 2024-09-14 4187/week @ 2024-09-21 4168/week @ 2024-09-28 4329/week @ 2024-10-05 4722/week @ 2024-10-12 5567/week @ 2024-10-19 4942/week @ 2024-10-26 3531/week @ 2024-11-02

19,542 downloads per month
Used in 16 crates (8 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
~90K SLoC