Struct FixedSizeQueue

Source
#[repr(C)]
pub struct FixedSizeQueue<T, const CAPACITY: usize> { /* private fields */ }
Expand description

Relocatable queue with compile time fixed size capacity. In contrast to its counterpart the Queue it is movable.

Implementations§

Source§

impl<T, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>

Source

pub fn new() -> Self

Creates a new queue.

Source

pub fn is_empty(&self) -> bool

Returns true if the queue is empty, otherwise false

Source

pub fn capacity(&self) -> usize

Returns the capacity of the queue

Source

pub fn len(&self) -> usize

Returns the number of elements inside the queue

Source

pub fn is_full(&self) -> bool

Returns true if the queue is full, otherwise false

Source

pub fn clear(&mut self)

Removes all elements from the queue

Source

pub fn peek(&self) -> Option<&T>

Returns a reference to the element from the beginning of the queue without removing it. If the queue is empty it returns None.

Source

pub fn peek_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the element from the beginning of the queue without removing it. If the queue is empty it returns None.

Source

pub fn pop(&mut self) -> Option<T>

Removes the element from the beginning of the queue. If the queue is empty it returns None.

Source

pub fn push(&mut self, value: T) -> bool

Adds an element at the end of the queue. If the queue is full it returns false, otherwise true.

Source

pub fn push_with_overflow(&mut self, value: T) -> Option<T>

Adds an element at the end of the queue. If the queue is full it returns the oldest element, otherwise None.

Source§

impl<T: Copy + Debug, const CAPACITY: usize> FixedSizeQueue<T, CAPACITY>

Source

pub unsafe fn get_unchecked(&self, index: usize) -> T

Returns a copy of the element stored at index. The index is starting by 0 for the first element until FixedSizeQueue::len().

§Safety
  • The index must be not out of bounds
Source

pub fn get(&self, index: usize) -> T

Returns a copy of the element stored at index. The index is starting by 0 for the first element until FixedSizeQueue::len().

Trait Implementations§

Source§

impl<T: Debug, const CAPACITY: usize> Debug for FixedSizeQueue<T, CAPACITY>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const CAPACITY: usize> Default for FixedSizeQueue<T, CAPACITY>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, const CAPACITY: usize> PlacementDefault for FixedSizeQueue<T, CAPACITY>

Source§

unsafe fn placement_default(ptr: *mut Self)

Performs a initialization of Self at the provided memory position with Default::default(). Read more
Source§

impl<T: ZeroCopySend, const CAPACITY: usize> ZeroCopySend for FixedSizeQueue<T, CAPACITY>

Source§

unsafe fn type_name() -> &'static str

The unique identifier of the type. It shall be used to identify a specific type accross processes and languages. Read more
Source§

impl<T: Send, const CAPACITY: usize> Send for FixedSizeQueue<T, CAPACITY>

Auto Trait Implementations§

§

impl<T, const CAPACITY: usize> !Freeze for FixedSizeQueue<T, CAPACITY>

§

impl<T, const CAPACITY: usize> RefUnwindSafe for FixedSizeQueue<T, CAPACITY>
where T: RefUnwindSafe,

§

impl<T, const CAPACITY: usize> Sync for FixedSizeQueue<T, CAPACITY>
where T: Sync,

§

impl<T, const CAPACITY: usize> Unpin for FixedSizeQueue<T, CAPACITY>
where T: Unpin,

§

impl<T, const CAPACITY: usize> UnwindSafe for FixedSizeQueue<T, CAPACITY>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.