pub trait Controller {
type Item;
// Required methods
fn is_full(&self, q: &VecDeque<Self::Item>) -> bool;
fn is_overflow(&self, q: &VecDeque<Self::Item>) -> bool;
fn check(
&self,
q: &VecDeque<Self::Item>,
item: &Self::Item,
) -> Result<(), CheckErr>;
fn reg(&mut self, q: &VecDeque<Self::Item>, item: &Self::Item);
fn dereg(&mut self, item: &Self::Item);
// Provided method
fn size_hint(&self) -> Option<usize> { ... }
}
Expand description
Implemented for objects that are used to monitor/control queue limits.
Required Associated Types§
Required Methods§
Sourcefn is_full(&self, q: &VecDeque<Self::Item>) -> bool
fn is_full(&self, q: &VecDeque<Self::Item>) -> bool
Check if queue is full/overflown.
Implementor return true
if queue is either full or has overflown.
If an implementation does not impose any upper limits, this must return
false
.
Sourcefn is_overflow(&self, q: &VecDeque<Self::Item>) -> bool
fn is_overflow(&self, q: &VecDeque<Self::Item>) -> bool
Check if queue is overflown.
Returns true
if there’s more data than is maximum allowed. Returns
false
if the queue is exactly full or has less data.
If an implementation does not impose any upper limits, this must return
false
.
Sourcefn check(
&self,
q: &VecDeque<Self::Item>,
item: &Self::Item,
) -> Result<(), CheckErr>
fn check( &self, q: &VecDeque<Self::Item>, item: &Self::Item, ) -> Result<(), CheckErr>
Check whether a new item would fit in queue.
§Errors
CheckErr::CantFit
means the item will never, sans potential
Controller
reconfiguration, be able to fit in the queue.
CheckErr::WontFit
means the item will currently not fit, but may be
able to do so if the operation is retried later.