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]>,
pub 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]>,
pub const fn new() -> Self
[src]
Creates an empty ring buffer with capacity equals to the length of the array A
minus
one.
pub fn capacity(&self) -> usize
[src]
Returns the maximum number of elements the ring buffer can hold
pub fn dequeue(&mut self) -> Option<T>
[src]
Returns the item in the front of the queue, or None
if the queue is empty
pub 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
pub fn len(&self) -> usize
[src]
Returns the number of elements in the queue
pub fn is_empty(&self) -> bool
[src]
Returns true
if the ring buffer has a length of 0
ⓘImportant traits for Iter<'a, T, A>pub fn iter(&self) -> Iter<T, A>
[src]
Iterates from the front of the queue to the back
ⓘImportant traits for IterMut<'a, T, A>pub 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]>,
Auto Trait Implementations
impl<T, A> Send for RingBuffer<T, A> where
A: Send,
T: Send,
A: Send,
T: Send,