CompleteIo
A thread-per-core Rust IO drivers and async runtime backed by IOCP/io_uring/mio. The name comes from "completion-based IO".
This repository is a fork of compio.
Why not Compio?
The project has different goals:
-
provide low overhead IO drivers that preallocate memory on initialization
-
drivers API accepts non-'static IO buffers
- drivers don't own buffers
- buffers are required to be Unpin
-
bias towards IoUring API to achieve zero-cost abstraction on Linux:
- fixed size submission queue for operations
- external runtime could submit an external queue of not yet queued operations as a single batch
- timers are exposed as
Timeoutoperation and use suspend-aware CLOCK_BOOTTIME clock source when it's available
-
Async runtime is an example runtime to test implementation of drivers
Quick start
With runtime feature enabled, we can use the high level APIs to perform fs & net IO.
use ;
let buffer = block_on;
println!;
While you can also control the low-level driver manually:
use ArrayVec;
use VecDeque;
use ;
let mut driver = new.unwrap;
let file = open.unwrap;
// Attach the `RawFd` to driver first.
driver.attach.unwrap;
// Create operation and push it to the driver.
let mut op = new;
let mut ops = from;
driver.push_queue;
// Poll the driver and wait for IO completed.
let mut entries = new;
unsafe
let entry = entries.drain.next.unwrap;
assert_eq!;
// Resize the buffer by return value.
let n = entry.into_result.unwrap;
let mut buffer = op.into_inner;
unsafe
println!;