hd-wallet 0.7.0

HD wallets derivation
Documentation
//! When something goes wrong

use core::fmt;

/// Length of the argument is not valid
#[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 {}

/// Value was out of range
#[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 {}

/// Error returned by parsing child index
#[derive(Debug)]
pub enum ParseChildIndexError {
    /// Indicates that parsing an `u32` integer failed
    ParseInt(core::num::ParseIntError),
    /// Parsed index was out of acceptable range
    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),
        }
    }
}