Expand description
§linebuffer
A circular-/ringbuffer for dynamic sized elements.
It’s created specifically for storing line-like data in a upcounting fashion.
§Example
use linebuffer::{typenum, LineBuffer};
// create a buffer of max 2048 entries/lines and 512KB data cache
// with the additional flag type ()
let mut buffer: LineBuffer<(), typenum::U2048> = LineBuffer::new(512_000);
let data = String::from("Some data stuff");
buffer.insert(data.as_bytes(),());
assert_eq!(buffer.get(0),Some((data.as_bytes(), &())));
§Details
When creating a linebuffer the amount of elements(lines) and the data size is specified.
This means for 8 elements and a data size of 16 the buffer will wrap when either 8 elements or more than 16 bytes were written.
If we would insert 8 elements of 4 bytes, our buffer would thus already wrap after 4 elements.
Please note that the element amount is stack allocated currently. Consequently setting a high amount of elements can lead to stack overflow.
Re-exports§
pub use generic_array::typenum;
Structs§
- Entry
- Implementation detail, currently leaked by generic declaration
- Iter
- Iterator over entries in LineBuffer
- Line
Buffer - Circular Line Buffer