A tri-partite ring buffer is similar to a circular buffer, but data is inserted in three revolving regions of the buffer space. This allows reads to return contiguous blocks of memory, even if they span a region that would normally include a wrap-around in a circular buffer. It's especially useful for APIs requiring blocks of contiguous memory, eliminating the need to copy data into an interim buffer before use.
Its is heavily inspired by the article of Simon Cooke's Bip-Buffer.
```rust use triskell::TRBuffer;
// Creates a TRBuffer of u8 and allocates 8 elements.
let mut buffer: TRBuffer
The capacity of a tri-partite ring buffer is the amount of space allocated for any future elements that will be added onto it. If a reservation exceeds its capacity, its capacity will automatically be increased.
There is two allocation strategy: * AllocationStrategy::Exact: Reserves the minimum capacity for at least additional more elements to be inserted in the given TRBuffer. * AllocationStrategy::AtLeast: Reserves capacity for a least additional more elements to be inserted in the given TRBuffer.
```rust use triskell::{TRBuffer, AllocationStrategy};
let mut buffer: TRBuffer
buffer.setallocationstrategy(AllocationStrategy::Exact); ```
As its name imply a tri-partite ring buffer use three regions instead of two. This allows to push data at the back and/or at the front of the buffer.