Expand description
§randomio
Async random-access I/O capability traits for Rust.
Think of this crate as:
std::io::Write→ sequential writestokio::io::AsyncWrite→ async sequential writesrandomio::AsyncRandomWrite→ async offset writes
If your device can read or write bytes at arbitrary offsets (files, block devices, object stores, io_uring, network storage), this crate defines the minimal traits to express that capability.
§Why randomio?
Rust currently provides:
- sequential I/O (
Read/Write) - async sequential I/O (
AsyncRead/AsyncWrite)
But there is no standard abstraction for random-access async I/O.
Libraries end up inventing incompatible write_at APIs.
randomio fills that gap with:
- zero-cost traits
- poll-based primitives
- no allocation
- no runtime coupling
- no policy
This crate only describes what a backend CAN do. Higher layers decide how it SHOULD be used.
§Design Principles
- Capability, not policy
- Zero buffering
- Zero scheduling
- Zero allocation
- Runtime-agnostic
no_stdcompatible
If you need buffering, batching, WAL, durability tracking,
or sinks/streams, build them in higher-level crates
(e.g. randomio-sink).
§Core Types
§Core Traits
AsyncRandomWrite— offset writes + flush + syncAsyncRandomRead— offset reads
These traits intentionally use poll-style APIs
to avoid allocations and async_trait overhead.
§Example
use randomio::AsyncRandomWrite;
use std::{pin::Pin, task::{Context, Poll}};
fn write_block<W: AsyncRandomWrite>(
writer: Pin<&mut W>,
cx: &mut Context<'_>,
) -> Poll<std::io::Result<()>> {
writer.poll_write_at(cx, 4096, b"data")
}§Non-Goals
This crate will never include:
- buffering
- batching
- ordering guarantees
- durability semantics beyond OS
- runtimes
- adapters
async fnwrappers
Keeping this crate minimal ensures a stable, forever-frozen core.
§Stability
Starting from 1.0, the core traits and structs are intended to be
permanently stable. Only additive APIs will be introduced.
randomio is designed to be the foundational layer other crates build upon.
Modules§
- io
- I/O re-export for
stdenvironments. Traits, helpers, and type definitions for core I/O functionality.
Structs§
Traits§
- Async
Random Read - Re-export core traits. Optional read capability for asynchronous random-read I/O
- Async
Random Write - Re-export core traits. Core write capability for asynchronous random-write I/O