QueueChecker

Trait QueueChecker 

Source
pub trait QueueChecker<P> {
    // Required methods
    fn is_empty(&self) -> bool;
    fn is_full(&self) -> bool;
    fn len(&self) -> P;
    fn max_capacity(&self) -> P;
}
Available on crate feature queue only.
Expand description

Trait to define all information getter from the queue

use prosa_utils::queue::QueueChecker;

fn queue_checker<Q>(queue: Q)
where
    Q: QueueChecker<usize>,
{
    if queue.is_empty() {
        assert!(!queue.is_full());
        assert_eq!(0, queue.len());
    } else if queue.is_full() {
        assert!(!queue.is_empty());
        assert_eq!(queue.max_capacity(), queue.len());
    }
}

Required Methods§

Source

fn is_empty(&self) -> bool

Checks if the queue is empty. Prefer this method over len() != 0

Source

fn is_full(&self) -> bool

Checks if the queue is full. Prefer this method over len() != max_capacity()

Source

fn len(&self) -> P

Returns the number of item in the queue.

Source

fn max_capacity(&self) -> P

Returns the maximum item capacity of the queue.

Implementors§

Source§

impl<T, const N: usize> QueueChecker<u16> for LockFreeQueueU16<T, N>

Source§

impl<T, const N: usize> QueueChecker<u16> for LockFreeOptQueueU16<T, N>

Source§

impl<T, const N: usize> QueueChecker<u32> for LockFreeQueueU32<T, N>

Source§

impl<T, const N: usize> QueueChecker<u32> for LockFreeOptQueueU32<T, N>