use core::fmt;
#[derive(Debug)]
pub struct InvalidLength;
impl fmt::Display for InvalidLength {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("invalid length")
}
}
impl core::error::Error for InvalidLength {}
#[derive(Debug)]
pub struct OutOfRange;
impl fmt::Display for OutOfRange {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("out of range")
}
}
impl core::error::Error for OutOfRange {}
#[derive(Debug)]
pub enum ParseChildIndexError {
ParseInt(core::num::ParseIntError),
IndexNotInRange(OutOfRange),
}
impl fmt::Display for ParseChildIndexError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ParseInt(_) => f.write_str("child index is not valid u32 integer"),
Self::IndexNotInRange(_) => f.write_str("child index is not in acceptable range"),
}
}
}
impl core::error::Error for ParseChildIndexError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
ParseChildIndexError::ParseInt(e) => Some(e),
ParseChildIndexError::IndexNotInRange(e) => Some(e),
}
}
}