1pub mod file_header;
6pub mod packet_header;
7mod sync;
8pub use sync::*;
9#[cfg(feature = "tokio-async")]
10mod tokio_impl;
11use thiserror::Error;
12#[cfg(feature = "tokio-async")]
13pub use tokio_impl::AsyncPcapReader;
14
15use crate::{byte_order::UnexpectedSize, link_type::InvalidLinkType};
16
17#[derive(Debug, Error)]
19pub enum PcapParseError {
20 #[error(transparent)]
21 IO(#[from] std::io::Error),
22 #[error("Invalid magic number got {0:?}")]
23 InvalidMagicNumber(Option<[u8; 4]>),
24 #[error(transparent)]
25 InvalidLinkType(#[from] InvalidLinkType),
26 #[error(
27 "Invalid packet length: snap length {snap_length} is greater than included length {incl_len}"
28 )]
29 InvalidPacketLength { snap_length: u32, incl_len: u32 },
30 #[error("Invalid version")]
31 InvalidVersion,
32 #[error(transparent)]
34 TryFromSliceError(#[from] std::array::TryFromSliceError),
35 #[error(transparent)]
36 UnexpectedSize(#[from] UnexpectedSize),
37}