mac_addr/
error.rs

1use core::fmt;
2
3/// Error returned when parsing a MAC address with [`core::str::FromStr`].
4#[derive(Copy, Debug, PartialEq, Eq, Clone)]
5pub enum ParseMacAddrError {
6    /// Input contained more than 6 components.
7    TooManyComponents,
8    /// Input contained fewer than 6 components.
9    TooFewComponents,
10    /// A component was invalid hex or empty.
11    InvalidComponent,
12}
13
14impl fmt::Display for ParseMacAddrError {
15    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16        let s = match *self {
17            ParseMacAddrError::TooManyComponents => "Too many components in a MAC address string",
18            ParseMacAddrError::TooFewComponents => "Too few components in a MAC address string",
19            ParseMacAddrError::InvalidComponent => "Invalid component in a MAC address string",
20        };
21        f.write_str(s)
22    }
23}
24
25#[cfg(feature = "std")]
26impl std::error::Error for ParseMacAddrError {}