PcapReader

Struct PcapReader 

Source
pub struct PcapReader { /* private fields */ }
Expand description

PCAP数据集读取器

提供对PCAP数据集的高性能读取功能,支持:

  • 自动索引管理和验证
  • 顺序读取和文件切换
  • 智能缓存和性能优化
  • 多文件数据集统一访问

Implementations§

Source§

impl PcapReader

Source

pub fn new<P: AsRef<Path>>(base_path: P, dataset_name: &str) -> PcapResult<Self>

创建新的PCAP读取器

§参数
  • base_path - 基础路径
  • dataset_name - 数据集名称
§返回

返回初始化后的读取器实例

Source

pub fn new_with_config<P: AsRef<Path>>( base_path: P, dataset_name: &str, configuration: ReaderConfig, ) -> PcapResult<Self>

创建新的PCAP读取器(带配置)

§参数
  • base_path - 基础路径
  • dataset_name - 数据集名称
  • configuration - 读取器配置信息
§返回

返回初始化后的读取器实例

Source

pub fn initialize(&mut self) -> PcapResult<()>

初始化读取器

确保索引可用并准备好读取操作

Source

pub fn get_dataset_info(&mut self) -> PcapResult<DatasetInfo>

获取数据集信息

Source

pub fn get_file_info_list(&mut self) -> PcapResult<Vec<FileInfo>>

获取文件信息列表

Source

pub fn dataset_path(&self) -> &Path

获取数据集路径

Source

pub fn dataset_name(&self) -> &str

获取数据集名称

Source

pub fn read_packet(&mut self) -> PcapResult<Option<DataPacket>>

读取下一个数据包

§返回
  • Ok(Some(packet)) - 成功读取到数据包
  • Ok(None) - 到达文件末尾,无更多数据包
  • Err(error) - 读取过程中发生错误
Source

pub fn read_packets(&mut self, count: usize) -> PcapResult<Vec<DataPacket>>

批量读取多个数据包

§参数
  • count - 要读取的数据包数量
§返回
Source

pub fn reset(&mut self) -> PcapResult<()>

重置读取器到数据集开始位置

将读取器重置到数据集的开始位置,后续读取将从第一个数据包开始。

Source

pub fn index(&self) -> &IndexManager

获取索引管理器的引用 允许外部通过 reader.index().method() 的方式访问索引功能

Source

pub fn index_mut(&mut self) -> &mut IndexManager

获取索引管理器的可变引用 允许外部通过 reader.index_mut().method() 的方式访问索引功能

Source

pub fn get_cache_stats(&self) -> &CacheStats

获取缓存统计信息

Source

pub fn clear_cache(&mut self) -> PcapResult<()>

清理缓存

Trait Implementations§

Source§

impl Drop for PcapReader

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.