pub trait RingBuffer<T>: Sized {
    fn len(&self) -> usize;
    fn capacity(&self) -> usize;

    fn is_empty(&self) -> bool { ... }
    fn is_full(&self) -> bool { ... }
}
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

Required methods

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.

Returns the capacity of the buffer.

Provided methods

Returns true if the buffer is entirely empty.

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

Implementors