pub trait RingBuffer<T>: Sized {
    // Provided methods
    fn len(&self) -> usize { ... }
    fn is_empty(&self) -> bool { ... }
    fn is_full(&self) -> bool { ... }
    fn capacity(&self) -> usize { ... }
}
Expand description

RingBuffer is a trait defining the standard interface for all RingBuffer implementations (AllocRingBuffer, ConstGenericRingBuffer)

This trait is not object safe, so can’t be used dynamically. However it is possible to define a generic function over types implementing RingBuffer.

Most actual functionality of ringbuffers is contained in the extension traits RingBufferExt, RingBufferRead and RingBufferWrite

Provided Methods§

source

fn len(&self) -> usize

Returns the length of the internal buffer. This length grows up to the capacity and then stops growing. This is because when the length is reached, new items are appended at the start.

source

fn is_empty(&self) -> bool

Returns true if the buffer is entirely empty.

source

fn is_full(&self) -> bool

Returns true when the length of the ringbuffer equals the capacity. This happens whenever more elements than capacity have been pushed to the buffer.

source

fn capacity(&self) -> usize

Returns the capacity of the buffer.

Implementors§

source§

impl<T> RingBuffer<T> for GrowableAllocRingBuffer<T>

source§

impl<T, SIZE: RingbufferSize> RingBuffer<T> for AllocRingBuffer<T, SIZE>

source§

impl<T, const CAP: usize> RingBuffer<T> for ConstGenericRingBuffer<T, CAP>