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
pub type PendulumResult<T1, T2> = Result<T1, PendulumError<T2>>;
#[derive(Debug)]
pub struct PendulumError<T> {
item: T,
kind: PendulumErrorKind
}
impl<T> PendulumError<T> {
pub fn new(item: T, kind: PendulumErrorKind) -> PendulumError<T> {
PendulumError{ item: item, kind: kind }
}
pub fn kind(&self) -> &PendulumErrorKind {
&self.kind
}
pub fn item(&self) -> &T {
&self.item
}
pub fn into_parts(self) -> (T, PendulumErrorKind) {
(self.item, self.kind)
}
}
#[derive(Debug)]
pub enum PendulumErrorKind {
MaxCapacityReached,
MaxTimeoutExceeded
}