Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tokio-rs/tokio-uring
An io_uring backed runtime for Rust
https://github.com/tokio-rs/tokio-uring
Last synced: 3 months ago
JSON representation
An io_uring backed runtime for Rust
- Host: GitHub
- URL: https://github.com/tokio-rs/tokio-uring
- Owner: tokio-rs
- License: mit
- Created: 2021-03-30T17:48:00.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-02T05:03:27.000Z (8 months ago)
- Last Synced: 2024-04-13T21:57:34.739Z (7 months ago)
- Language: Rust
- Homepage:
- Size: 392 KB
- Stars: 995
- Watchers: 37
- Forks: 110
- Open Issues: 72
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-iouring - tokio-uring
README
# tokio-uring
This crate provides [`io-uring`] for [Tokio] by exposing a new Runtime that is
compatible with Tokio but also can drive [`io-uring`]-backed resources. Any
library that works with [Tokio] also works with `tokio-uring`. The crate
provides new resource types that work with [`io-uring`].[`io-uring`]: https://unixism.net/loti/
[Tokio]: https://github.com/tokio-rs/tokio
[`fs::File`]: https://docs.rs/tokio-uring/latest/tokio_uring/fs/struct.File.html[API Docs](https://docs.rs/tokio-uring/latest/tokio_uring) |
[Chat](https://discord.gg/tokio)# Getting started
Using `tokio-uring` requires starting a [`tokio-uring`] runtime. This
runtime internally manages the main Tokio runtime and a `io-uring` driver.In your Cargo.toml:
```toml
[dependencies]
tokio-uring = { version = "0.5.0" }
```
In your main.rs:
```rust
use tokio_uring::fs::File;fn main() -> Result<(), Box> {
tokio_uring::start(async {
// Open a file
let file = File::open("hello.txt").await?;let buf = vec![0; 4096];
// Read some data, the buffer is passed by ownership and
// submitted to the kernel. When the operation completes,
// we get the buffer back.
let (res, buf) = file.read_at(buf, 0).await;
let n = res?;// Display the contents
println!("{:?}", &buf[..n]);Ok(())
})
}
```
## Requirements
`tokio-uring` requires a very recent linux kernel. (Not even all kernels with io_uring support will work)
In particular `5.4.0` does not work (This is standard on Ubuntu 20.4). However `5.11.0` (the ubuntu hwe image) does work.
## Project statusThe `tokio-uring` project is still very young. Currently, we are focusing on
supporting filesystem and network operations. Eventually, we will add safe APIs for all
io-uring compatible operations.## License
This project is licensed under the [MIT license].
[MIT license]: LICENSE
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in tokio-uring by you, shall be licensed as MIT, without any
additional terms or conditions.