#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
IndexOutOfBounds {
index: u64,
tree_size: u64,
},
InvalidOldSize {
old_size: u64,
new_size: u64,
},
EmptyTree,
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::IndexOutOfBounds { index, tree_size } => {
write!(
f,
"leaf index {index} out of bounds for tree of size {tree_size}"
)
}
Error::InvalidOldSize { old_size, new_size } => {
write!(
f,
"invalid old size {old_size} for consistency proof against tree of size \
{new_size}"
)
}
Error::EmptyTree => write!(f, "operation requires a non-empty tree"),
}
}
}
impl std::error::Error for Error {}