use std::time::{Duration, SystemTime, UNIX_EPOCH};
pub use pktbaffle::codegen::LinkType;
#[derive(Debug, Clone)]
pub struct Packet {
pub data: Vec<u8>,
pub timestamp: SystemTime,
pub orig_len: u32,
pub link_type: LinkType,
}
impl Packet {
pub(crate) fn new(
data: Vec<u8>,
ts_sec: u64,
ts_nsec: u32,
orig_len: u32,
link_type: LinkType,
) -> Self {
let timestamp = UNIX_EPOCH + Duration::new(ts_sec, ts_nsec);
Self {
data,
timestamp,
orig_len,
link_type,
}
}
pub fn is_truncated(&self) -> bool {
self.data.len() < self.orig_len as usize
}
}