PcapWriter

Struct PcapWriter 

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

PCAP数据集写入器

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

  • 自动文件管理和切换
  • 智能索引生成和更新
  • 高性能写入优化
  • 数据完整性保证

Implementations§

Source§

impl PcapWriter

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: WriterConfig, ) -> PcapResult<Self>

创建新的PCAP写入器(带配置)

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

返回初始化后的写入器实例

Source

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

初始化写入器

Source

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

完成写入并生成索引

Source

pub fn get_dataset_info(&self) -> DatasetInfo

获取数据集信息

Source

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

获取文件信息列表

Source

pub fn index(&self) -> &IndexManager

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

Source

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

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

Source

pub fn dataset_path(&self) -> &Path

获取数据集路径

Source

pub fn dataset_name(&self) -> &str

获取数据集名称

Source

pub fn write_packet(&mut self, packet: &DataPacket) -> PcapResult<()>

写入单个数据包

§参数
  • packet - 要写入的数据包
§返回
  • Ok(()) - 成功写入数据包
  • Err(error) - 写入过程中发生错误
Source

pub fn write_packets(&mut self, packets: &[DataPacket]) -> PcapResult<()>

批量写入多个数据包

§参数
  • packets - 要写入的数据包列表
§返回
Source

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

刷新当前文件

将当前文件的缓冲区数据写入磁盘,确保数据完整性。

Source

pub fn get_cache_stats(&self) -> CacheStats

获取缓存统计信息

Source

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

清理缓存

Trait Implementations§

Source§

impl Drop for PcapWriter

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.