ethertype 0.3.4

IEEE 802 EtherType with protocol descriptions
Documentation
use core::{fmt, num::ParseIntError};

/// An error which can be returned when parsing an [`EtherType`](`crate::EtherType`)
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, Eq, PartialEq, Debug)]
#[non_exhaustive]
pub enum ParseEtherTypeError {
    InvalidLength,
    ParseInt(ParseIntError),
}

impl fmt::Display for ParseEtherTypeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            ParseEtherTypeError::InvalidLength => {
                write!(f, "expected a 4-digit hexadecimal string")
            }
            ParseEtherTypeError::ParseInt(err) => write!(f, "{}", err),
        }
    }
}

#[cfg(feature = "std")]
mod std {
    use std::error::Error;

    use super::ParseEtherTypeError;

    impl Error for ParseEtherTypeError {}
}