pub struct Queue<T: Clone, const N: usize> { /* private fields */ }Expand description
A ring-buffer based queue, with N elements stored inline. TODO: Make this growable.
Implementations§
Source§impl<T: Clone + Copy, const N: usize> Queue<T, N>
impl<T: Clone + Copy, const N: usize> Queue<T, N>
Sourcepub fn push_back(&mut self, value: T) -> Result<(), KernelError>
pub fn push_back(&mut self, value: T) -> Result<(), KernelError>
Push a value onto the back of the queue.
value - The value to push onto the back of the queue.
Returns Ok(()) if the value was pushed onto the back of the queue, or an error if the queue is full.
Sourcepub fn pop_front(&mut self) -> Option<T>
pub fn pop_front(&mut self) -> Option<T>
Pop a value from the front of the queue.
Returns the value at the front of the queue, or None if the queue is empty.
Sourcepub fn insert(&mut self, index: usize, value: T) -> Result<(), KernelError>
pub fn insert(&mut self, index: usize, value: T) -> Result<(), KernelError>
Insert a value at the given index in the queue.
index - The index to insert the value at.
value - The value to insert.
Returns Ok(()) if the value was inserted at the given index, or an error if the index is out of bounds.
Sourcepub fn grow_capacity(&mut self, new_size: usize) -> Result<(), KernelError>
pub fn grow_capacity(&mut self, new_size: usize) -> Result<(), KernelError>
Increases total space in the queue preserving queue-integrity, potentially reallocating and copying existing contents
new_size - The total amount of space in the queue afterwards
Returns Ok(()) if the queue was successfully enlargened or the requested size was smaller than the current capacity.
Returns An error if the queue could not be grown