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
use std::{error, fmt};
#[derive(Debug, Clone)]
pub enum Error {
FullBuffer,
IndexOutOfBounds,
LeafNotFound,
Other(String),
}
impl error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
Error::FullBuffer => write!(
f,
"The size of the buffer cannot be greater than the arity of the merkle tree."
),
Error::IndexOutOfBounds => write!(f, "The referenced index is outs of bounds."),
Error::LeafNotFound => write!(f, "The provided leaf is not present in the tree."),
Error::Other(s) => write!(f, "{}", s),
}
}
}