An easy-to-use low-level ring buffer implementation that leverages virtual address space trickery for Rust ๐ฆ
- Create a new
QuantumRing
with asize
size
will be treated as a lower boundary. The actual size may be greater, because the buffer has to be page aligned.
let qring = QuantumRing::new_with_size(1024, PageSizes::all()) .expect("unable to create QuantumRing");
- Read/Write
- Read using direct access
let slice: &[u8] = qring.read_slice(); // do something with 0 <= n < slice.len() == qring.read_len() bytes unsafe { qring.advance_read(n) };
- Write using direct access
let slice: &mut [u8] = qring.write_slice(); // overwrite 0 <= n < slice.len() == qring.write_len() bytes from slice unsafe { qring.advance_write(n) };
QuantumRing
implementsstd::io::Read
QuantumRing
implementsstd::io::Write
QuantumRing
implementsfutures_io::AsyncRead
(feature:futures
)QuantumRing
implementsfutures_io::AsyncWrite
(feature:futures
)QuantumRing
implementstokio_io::AsyncRead
(feature:tokio
)QuantumRing
implementstokio_io::AsyncWrite
(feature:tokio
)