| Crates.io | ringo-buff |
| lib.rs | ringo-buff |
| version | 0.1.0 |
| created_at | 2025-11-20 14:47:56.519168+00 |
| updated_at | 2025-11-20 14:47:56.519168+00 |
| description | Ring buffers for bytes, with heap and stack storage. |
| homepage | |
| repository | https://github.com/rrauch/ringo-buff |
| max_upload_size | |
| id | 1942084 |
| size | 1,086,126 |
Ring buffers for bytes, with heap and stack storage.
ringo-buff provides a simple API for managing bytes in a circular buffer, supporting both heap and stack
storage strategies.
It can be used without allocating and should be usable in a no_std environment.
Useful for I/O buffering, streaming data, etc.
HeapBuffer (dynamic Vec) or StackBuffer (fixed array).consume (read) and commit (write) cursors.bytes traits and zeroize.Add this to your Cargo.toml:
[dependencies]
ringo-buff = "0.1.0"
Best for dynamic sizes or when large buffers are required.
use ringo_buff::HeapBuffer;
fn main() {
// Allocate a buffer with 1KB capacity
let mut buf = HeapBuffer::new(1024);
// WRITING: Get writable slices
let (first, _) = buf.as_mut_slices();
// ... write data into 'first' ...
// Advance the write cursor
buf.commit(50);
// READING: Get readable slices
let (head, tail) = buf.as_slices();
// ... process data ...
// Advance the read cursor
buf.consume(50);
}
Best for small, fixed buffers where heap allocation is undesirable.
use ringo_buff::StackBuffer;
fn main() {
// Create a buffer on the stack with 128 bytes capacity
let mut buf: StackBuffer<128> = StackBuffer::new();
// API is identical to HeapBuffer
assert_eq!(buf.capacity(), 128);
}
| Flag | Description | Default |
|---|---|---|
alloc |
Enables HeapBuffer and Vec support. |
Yes |
buf-trait |
Implements bytes::Buf and bytes::BufMut. |
No |
zeroize |
Securely wipes memory on drop via the zeroize crate. |
No |
hybrid-array |
Enables hybrid-array support for StackBuffer (e.g., StackBuffer<U1024>). |
No |
To use ringo-buff in an environment without an allocator, disable default features:
[dependencies]
ringo-buff = { version = "0.1.0", default-features = false }
This project is licensed under either of
at your option.