Expand description
§ringo-buff
Ring buffers for bytes, with heap and stack storage.
A simple, predictable ring buffer (circular buffer) implementation supporting both stack and heap storage strategies.
This crate provides a simple API for managing bytes in a circular buffer, useful for
I/O buffering, streaming data, etc. It can be used without allocating
and should be usable in a no_std environment.
§Quick Start
Choose your storage strategy:
HeapBuffer: Backed by aVec<u8>. Best for dynamic sizes or large buffers. Supports resizing at runtime.StackBuffer: Backed by an array. Best for fixed, small sizes where allocation is undesirable.
use ringo_buff::HeapBuffer;
// Create a buffer with 1024 bytes capacity
let mut buf = HeapBuffer::new(1024);
// Write data (advances write cursor)
let (first, _) = buf.as_mut_slices();
first[..3].copy_from_slice(b"foo");
buf.commit(3);
// Read data (advances read cursor)
let (first, _) = buf.as_slices();
assert_eq!(first, b"foo");
buf.consume(3);§Feature Flags
alloc(default): EnablesHeapBufferandVecsupport.buf-trait: Implementsbytes::Bufandbytes::BufMuttraits.zeroize: Clears memory on drop via thezeroizecrate.hybrid-array: Enableshybrid-arraysupport forStackBuffer, allowing sizes to be defined via types (e.g.,U1024).
Structs§
- Circular
Buffer - The core ring buffer logic generic over storage
S.
Traits§
- Array
Size hybrid-array - Trait which associates a
usizesize andArrayTypewith atypenum-providedUnsignedinteger.
Type Aliases§
- Heap
Buffer alloc - A circular buffer backed by a heap-allocated
Vec<u8>. - Stack
Buffer hybrid-array - A circular buffer backed by
hybrid_array::Array.