use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
InvalidArity(u64),
DuplicateAlgorithm(u64),
IndexGap {
index: u64,
len: u64,
},
EmptySeal,
MalformedSeal,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidArity(k) => write!(f, "arity {k} is outside the supported range 2..=256"),
Self::DuplicateAlgorithm(id) => write!(f, "algorithm {id} is already registered"),
Self::IndexGap { index, len } => {
write!(
f,
"index {index} leaves a gap in a dense tree of length {len} (max settable \
index is {len})"
)
},
Self::EmptySeal => write!(f, "cannot seal an empty tree: there is no root to carry"),
Self::MalformedSeal => {
write!(f, "the spine rejected the sealed resumable frontier")
},
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;