1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
),
}
}
}