Struct heapless::ring_buffer::RingBuffer
[−]
[src]
pub struct RingBuffer<T, A> where
A: Unsize<[T]>, { /* fields omitted */ }
An statically allocated ring buffer backed by an array A
Methods
impl<T, A> RingBuffer<T, A> where
A: Unsize<[T]>,
[src]
A: Unsize<[T]>,
fn split(&mut self) -> (Producer<T, A>, Consumer<T, A>)
[src]
Splits a statically allocated ring buffer into producer and consumer end points
impl<T, A> RingBuffer<T, A> where
A: Unsize<[T]>,
[src]
A: Unsize<[T]>,
const fn new() -> Self
[src]
Creates an empty ring buffer with capacity equals to the length of the array A
minus
one.
fn capacity(&self) -> usize
[src]
Returns the maximum number of elements the ring buffer can hold
fn dequeue(&mut self) -> Option<T>
[src]
Returns the item in the front of the queue, or None
if the queue is empty
fn enqueue(&mut self, item: T) -> Result<(), BufferFullError>
[src]
Adds an item
to the end of the queue
Returns BufferFullError
if the queue is full
fn len(&self) -> usize
[src]
Returns the number of elements in the queue
fn is_empty(&self) -> bool
[src]
Returns true
if the ring buffer has a length of 0
fn iter(&self) -> Iter<T, A>
[src]
Iterates from the front of the queue to the back
fn iter_mut(&mut self) -> IterMut<T, A>
[src]
Returns an iterator that allows modifying each value.
Trait Implementations
impl<T, A> Drop for RingBuffer<T, A> where
A: Unsize<[T]>,
[src]
A: Unsize<[T]>,
impl<'a, T, A> IntoIterator for &'a RingBuffer<T, A> where
A: Unsize<[T]>,
[src]
A: Unsize<[T]>,
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T, A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, T, A> IntoIterator for &'a mut RingBuffer<T, A> where
A: Unsize<[T]>,
[src]
A: Unsize<[T]>,