1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use core::fmt::{self, Display, Formatter};

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

#[derive(Debug, Clone)]
pub enum MacAddressError {
    /// including the violation of the case rule
    Invalid,
    /// may not be valid but missing separators is guaranteed
    SeparatorMust,
    /// may not be valid but separators seem to exist
    SeparatorNotAllow,
}

impl Display for MacAddressError {
    #[inline]
    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
        match self {
            MacAddressError::Invalid => f.write_str("invalid mac address"),
            MacAddressError::SeparatorMust => f.write_str("separators not found"),
            MacAddressError::SeparatorNotAllow => f.write_str("separators not allowed"),
        }
    }
}

#[cfg(feature = "std")]
impl Error for MacAddressError {}