pub struct PcapWriter<W: Write> { /* private fields */ }Expand description
The PcapReader struct allows reading packets from a packet capture.
Implementations§
Source§impl<W: Write> PcapWriter<W>
impl<W: Write> PcapWriter<W>
Sourcepub fn new(writer: W, opts: WriteOptions) -> Result<Self, PcapError>
pub fn new(writer: W, opts: WriteOptions) -> Result<Self, PcapError>
Create a new PcapWriter that writes the packet capture data to the specified Write.
Sourcepub fn append_unchecked(
writer: W,
opts: WriteOptions,
) -> Result<Self, PcapError>
pub fn append_unchecked( writer: W, opts: WriteOptions, ) -> Result<Self, PcapError>
Create a new PcapWriter that appends the packets to an existing Write. If the
WriteOptions specified here are different than those used to create the file, the
resulting file will be invalid.
Warning: Only append to created using PcapWriter::new on the same machine. Files
created on other architectures or from another tool/library might use different
timestamp formats or endianness, leading to data corruption.
Sourcepub fn append(stream: W) -> Result<Self, PcapError>
pub fn append(stream: W) -> Result<Self, PcapError>
Create a new PcapWriter that appends the packets to an existing stream, which must
support Read + Write + Seek so that the correct format options for the file can be
determined.
Sourcepub fn write(&mut self, packet: &CapturedPacket<'_>) -> Result<(), PcapError>
pub fn write(&mut self, packet: &CapturedPacket<'_>) -> Result<(), PcapError>
Write a package to the capture file.
Sourcepub fn take_writer(self) -> W
pub fn take_writer(self) -> W
Destroys this PcapWriter and returns access to the underlying Write.
Sourcepub fn get_options(&self) -> WriteOptions
pub fn get_options(&self) -> WriteOptions
The options used by this PcapWriter.