use lib::*;
#[derive(Debug)]
pub struct InconsistentCapacity {
capacity: NonZeroU32,
cell_weight: NonZeroU32,
}
impl InconsistentCapacity {
pub(crate) fn new(capacity: NonZeroU32, cell_weight: NonZeroU32) -> InconsistentCapacity {
InconsistentCapacity {
capacity,
cell_weight,
}
}
}
impl fmt::Display for InconsistentCapacity {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(
f,
"bucket capacity {} too small for a single cell with weight {}",
self.capacity, self.cell_weight
)
}
}
#[derive(Debug, PartialEq)]
pub enum NegativeMultiDecision<E: fmt::Display> {
BatchNonConforming(u32, E),
InsufficientCapacity(u32),
}
impl<E> fmt::Display for NegativeMultiDecision<E>
where
E: fmt::Display,
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
NegativeMultiDecision::BatchNonConforming(n, err) => write!(f, "{} cells: {}", n, err),
NegativeMultiDecision::InsufficientCapacity(n) => write!(
f,
"bucket does not have enough capacity to accomodate {} cells",
n
),
}
}
}