Skip to main content

Crate ringcore

Crate ringcore 

Source
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 the io_uring submission and completion queues.
  • op: Asynchronous operations (read, write, accept, etc.) that map to io_uring SQEs.
  • 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;

Modules§

executor
The RingCore Task Executor.
fs
Asynchronous File System operations.
net
Asynchronous Networking operations.
op
Asynchronous io_uring operations.
ring
Low-level io_uring abstraction.
sys
Low-level Linux io_uring bindings.