Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nanpuyue/tokio-fd
Non-blocking Read and Write a Linux/Unix File Descriptor
https://github.com/nanpuyue/tokio-fd
async linux mio non-blocking rust tokio
Last synced: 14 days ago
JSON representation
Non-blocking Read and Write a Linux/Unix File Descriptor
- Host: GitHub
- URL: https://github.com/nanpuyue/tokio-fd
- Owner: nanpuyue
- License: apache-2.0
- Created: 2020-01-31T06:04:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T14:18:34.000Z (almost 4 years ago)
- Last Synced: 2024-08-01T17:39:19.945Z (3 months ago)
- Topics: async, linux, mio, non-blocking, rust, tokio
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 18
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Non-blocking Read and Write a Linux/Unix File Descriptor
[![Crates.io](https://img.shields.io/crates/v/tokio-fd?color=green)](https://crates.io/crates/tokio-fd)
## Example
```rust
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
* [Apache License, Version 2.0](https://github.com/nanpuyue/tokio-fd/blob/master/LICENSE-APACHE)
* [MIT License](https://github.com/nanpuyue/tokio-fd/blob/master/LICENSE-MIT)at your option.