randomio
Async random-access I/O traits for Rust The
AsyncWrite/AsyncReadequivalent forwrite_at/read_at.
randomio provides minimal, zero-cost capability traits for writing and reading bytes at arbitrary offsets.
If you have ever needed:
- async
pwrite/pread - write chunks out-of-order
- download pieces into a sparse file
- persist blocks to disk/object storage
- build a WAL or chunk assembler
this crate provides the missing primitive.
Why randomio?
Rust has:
- sequential →
AsyncWrite - sequential →
AsyncRead
But there is no standard trait for random-access async I/O.
randomio fills that gap:
AsyncWrite → sequential only
AsyncRandomWrite → offset-based writes (this crate)
Quick Example
use AsyncRandomWrite;
use Pin;
use ;
Works for:
- files
- block devices
- object storage
- memory backends
- io_uring
- network storage
- WASM
What this crate provides
Core types
| Type | Description |
|---|---|
Range |
Half-open byte interval [start, end) |
Block<B> |
Data block at an offset with generic buffer |
Core traits
AsyncRandomWrite
AsyncRandomRead
Design principles
- Zero policy – no buffering, batching, or scheduling
- Zero-cost abstraction – no allocation, no
async_trait, no dynamic dispatch - Device agnostic – files, block devices, object stores, io_uring, WASM
- Capability, not runtime – describes what a backend can do, not how to use it
This crate is intentionally tiny and stable.
What this crate does NOT provide
These belong in higher-level runtimes:
- ❌ buffering / batching
- ❌ scheduling
- ❌ ordering guarantees
- ❌ durability tracking
- ❌ Sink/Stream adapters
- ❌ ingestion pipelines
Stability
When randomio reaches 1.0, the following are permanently frozen:
RangeBlockAsyncRandomWriteAsyncRandomRead- all method signatures
Only additive changes are allowed in 1.x.
Testing
randomio includes comprehensive test coverage:
- Unit tests for all core types and traits
- Property-based tests for edge cases
- Fuzz testing with production-grade targets
- write_model: Verifies correct offset writes
- read_write_consistency: Tests write_at → read_at consistency
- cancellation: Async cancellation safety
- overlap: Deterministic overlapping writes
Run tests:
# Run with sanitizers
RUSTFLAGS="-Zsanitizer=address"
# Run fuzz tests (requires cargo-fuzz)
for; do
done
License
This project is licensed under either of:
at your option.