#async #fs #io-uring

tokio-uring

io-uring support for the Tokio asynchronous runtime

5 releases (breaking)

0.4.0 Nov 5, 2022
0.3.0 Mar 4, 2022
0.2.0 Jan 9, 2022
0.1.0 Jul 19, 2021
0.0.0 Nov 14, 2020

#261 in Asynchronous

Download history 2491/week @ 2022-10-17 2384/week @ 2022-10-24 2614/week @ 2022-10-31 3115/week @ 2022-11-07 1996/week @ 2022-11-14 2851/week @ 2022-11-21 2711/week @ 2022-11-28 2825/week @ 2022-12-05 2555/week @ 2022-12-12 1613/week @ 2022-12-19 1224/week @ 2022-12-26 1804/week @ 2023-01-02 2054/week @ 2023-01-09 1954/week @ 2023-01-16 2000/week @ 2023-01-23 2972/week @ 2023-01-30

9,042 downloads per month
Used in 19 crates (13 directly)

MIT license

150KB
2.5K SLoC

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.

API Docs | Chat

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:

[dependencies]
tokio = { version = "0.4.0" }

In your main.rs:

use tokio_uring::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    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 status

The 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.

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.

Dependencies

~2.5–7MB
~109K SLoC