use std::fmt::Display;
use nom::error::{ErrorKind, ParseError};
use crate::constants::AddressFamilyId;
#[derive(Debug, Default)]
pub struct ParserContext {
pub four_octet_asn: Option<bool>,
pub address_family: Option<AddressFamilyId>,
}
#[derive(Debug)]
pub enum ToWireError {
OutBufferOverflow,
Other(eyre::Error),
}
impl Display for ToWireError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ToWireError::OutBufferOverflow => write!(f, "OutBufferOverflow"),
ToWireError::Other(report) => report.fmt(f),
}
}
}
impl std::error::Error for ToWireError {}
#[derive(Debug)]
pub enum BgpParserError<I> {
ProtocolError(ProtocolErrorValues),
CustomText(&'static str),
Eyre(eyre::ErrReport),
Nom(I, ErrorKind),
}
impl<I> ParseError<I> for BgpParserError<I> {
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
BgpParserError::Nom(input, kind)
}
fn append(_: I, _: ErrorKind, other: Self) -> Self {
other
}
}
#[derive(Debug)]
pub enum ProtocolErrorValues {
UnsupportedVersion(u8),
UnknownOpenOption(u8),
}