#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("not a capture: leading bytes {magic:02x?} are no pcap or pcapng magic")]
NotACapture {
magic: [u8; 4],
},
#[error("the capture ends part-way through a record")]
Truncated,
#[error("malformed capture: {reason}")]
Malformed {
reason: String,
},
#[error("i/o error reading the capture")]
Io(#[from] std::io::Error),
#[error("link type {link_type} is not dissected; this crate handles Ethernet (1) only")]
UnsupportedLinkType {
link_type: u32,
},
}
impl Error {
pub fn is_truncated(&self) -> bool {
matches!(self, Self::Truncated)
}
}
pub type Result<T, E = Error> = std::result::Result<T, E>;