pub trait RingBuf {
    type Item;

    fn new() -> Self;
    fn with_capacity(cap: usize) -> Self;
    fn capacity(&self) -> usize;
    fn len(&self) -> usize;
    fn can_push(&self) -> bool;
    fn push(&mut self, item: Self::Item);
    fn pop(&mut self) -> Self::Item;

    fn is_empty(&self) -> bool { ... }
}
Expand description

A Ring Buffer of items

Required Associated Types

The type of stored items inside the Ring Buffer

Required Methods

Creates a new instance of the Ring Buffer

Creates a new instance of the Ring Buffer with the given capacity. RingBuf implementations are allowed to ignore the capacity hint and utilize their default capacity.

The capacity of the buffer

The amount of stored items in the buffer

Returns true if there is enough space in the buffer to store another item.

Stores the item at the end of the buffer. Panics if there is not enough free space.

Returns the oldest item inside the buffer. Panics if there is no available item.

Provided Methods

Returns true if no item is stored inside the buffer.

Implementors