use std::{error::Error, fmt::Display};
#[derive(Debug)]
pub enum MplsError {
IoError(std::io::Error),
ParseError,
}
impl Error for MplsError {}
impl Display for MplsError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MplsError::IoError(e) => write!(f, "{}", e),
MplsError::ParseError => write!(f, "failed to parse byte stream as valid MPLS"),
}
}
}
impl From<std::io::Error> for MplsError {
fn from(err: std::io::Error) -> Self {
MplsError::IoError(err)
}
}