limq 0.4.0

Queue with a controller for monitoring queue elements
Documentation
use std::{collections::VecDeque, marker::PhantomData};

use super::{CheckErr, Controller};

/// [`LimQ`](crate::LimQ) controller that does not impose any limit.
pub struct NullCtrl<T> {
  _phantom: PhantomData<T>
}

impl<T> Controller for NullCtrl<T> {
  type Item = T;

  fn size_hint(&self) -> Option<usize> {
    None
  }

  fn is_full(&self, _q: &VecDeque<T>) -> bool {
    false
  }

  fn is_overflow(&self, _q: &VecDeque<T>) -> bool {
    false
  }

  fn check(
    &self,
    _q: &VecDeque<Self::Item>,
    _item: &Self::Item
  ) -> Result<(), CheckErr> {
    Ok(())
  }

  fn reg(&mut self, _q: &VecDeque<Self::Item>, _n: &Self::Item) {}

  fn dereg(&mut self, _n: &Self::Item) {}
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :