ringo-buff
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.
Features
- Dual Storage Backends: Choose between
HeapBuffer(dynamicVec) orStackBuffer(fixed array). - Predictable API: Explicit control over
consume(read) andcommit(write) cursors. - Zero-Copy Access: Access internal data directly via mutable/immutable slices.
- Ecosystem Integration: Optional support for
bytestraits andzeroize.
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Heap Buffer (Allocated)
Best for dynamic sizes or when large buffers are required.
use HeapBuffer;
Stack Buffer (Fixed Size)
Best for small, fixed buffers where heap allocation is undesirable.
use StackBuffer;
Feature Flags
| 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:
[]
= { = "0.1.0", = false }
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.