use std::{convert::Infallible, fmt};
#[derive(Debug)]
pub struct TryFromAccountIndexError;
impl fmt::Display for TryFromAccountIndexError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"`AccountIndex` does not contain an index of the target type"
)
}
}
impl std::error::Error for TryFromAccountIndexError {}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum AccountIdError {
MissingRoot,
InvalidDepth,
IndexRange,
InvalidSpecialBits,
NotIssuance,
NotLeaf,
InvalidLen,
}
impl fmt::Display for AccountIdError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::MissingRoot => write!(f, "missing root account ID/index"),
Self::InvalidDepth => write!(f, "maximum account ID depth exceeded"),
Self::IndexRange => write!(
f,
"account index exceeds supported range for the account type"
),
Self::InvalidSpecialBits => {
write!(f, "raw account ID value has invalid special bit values")
}
Self::NotIssuance => write!(f, "expected issuance account for the base account ID"),
Self::NotLeaf => write!(f, "expected leaf account for the base account ID"),
Self::InvalidLen => write!(f, "invalid length for raw ID byte slice"),
}
}
}
impl std::error::Error for AccountIdError {}
impl From<Infallible> for AccountIdError {
#[inline]
fn from(_error: Infallible) -> Self {
unreachable!()
}
}