Expand description
§RingCore
A minimalist async runtime powered by Linux’s io_uring.
RingCore provides a transparent, “from-scratch” implementation of an asynchronous runtime. It is designed for educational purposes and high-performance I/O tasks where transparency over the underlying kernel operations is preferred.
§Key Components
executor: A single-threaded task scheduler and event loop.ring: Low-level abstraction over theio_uringsubmission and completion queues.op: Asynchronous operations (read, write, accept, etc.) that map toio_uringSQEs.net/fs: High-level wrappers for networking and file system operations.
§Example: Simple Echo Server
use ringcore::{run, spawn, TcpListener};
fn main() {
spawn(async {
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
loop {
let (stream, _) = listener.accept().await.unwrap();
spawn(async move {
let mut buf = [0u8; 1024];
let n = stream.read(&mut buf).await.unwrap();
stream.write(&buf[..n]).await.unwrap();
});
}
});
run();
}Re-exports§
pub use executor::run;pub use executor::spawn;pub use executor::init;pub use executor::RING;pub use net::TcpListener;pub use net::TcpStream;pub use fs::File;