use core::error;
use core::fmt::{Debug, Display, Formatter};
use crate::error::UnexpectedBufferEndError;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum ParseIeee802_1QError {
UnexpectedBufferEnd(UnexpectedBufferEndError),
STagWithoutCTag,
}
impl From<UnexpectedBufferEndError> for ParseIeee802_1QError {
#[inline]
fn from(value: UnexpectedBufferEndError) -> Self {
Self::UnexpectedBufferEnd(value)
}
}
impl Display for ParseIeee802_1QError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Self::STagWithoutCTag => {
write!(
f,
"Ethernet frame has service tag without client tag in IEEE802.1Q header"
)
}
Self::UnexpectedBufferEnd(err) => {
write!(f, "{err}")
}
}
}
}
impl error::Error for ParseIeee802_1QError {}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct NotDoubleTaggedError;
impl Display for NotDoubleTaggedError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "Not double tagged")
}
}
impl error::Error for NotDoubleTaggedError {}