Debian Codegraph @

README.md

raw symbols SCIP
1 # Non-blocking Read and Write a Linux/Unix File Descriptor
2
3 [![Crates.io](https://img.shields.io/crates/v/tokio-fd?color=green)](https://crates.io/crates/tokio-fd)
4
5 ## Example
6
7 ```rust
8 use std::convert::TryFrom;
9 use std::io::Result;
10
11 use tokio::prelude::*;
12 use tokio_fd::AsyncFd;
13
14 #[tokio::main]
15 async fn main() -> Result<()> {
16 let mut stdin = AsyncFd::try_from(libc::STDIN_FILENO)?;
17 let mut stdout = AsyncFd::try_from(libc::STDOUT_FILENO)?;
18 let mut buf = vec![0; 1024];
19
20 while let Ok(n) = stdin.read(&mut buf).await {
21 stdout.write(&buf[..n]).await?;
22 }
23 Ok(())
24 }
25 ```
26
27 ## License
28
29 This project is licensed under either of
30
31 * [Apache License, Version 2.0](https://github.com/nanpuyue/tokio-fd/blob/master/LICENSE-APACHE)
32 * [MIT License](https://github.com/nanpuyue/tokio-fd/blob/master/LICENSE-MIT)
33
34 at your option.