Skip to main content

PcapWriter

Struct PcapWriter 

Source
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>

Source

pub fn new(writer: W, opts: WriteOptions) -> Result<Self, PcapError>

Create a new PcapWriter that writes the packet capture data to the specified Write.

Source

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.

Source

pub fn append(stream: W) -> Result<Self, PcapError>
where W: Read + Seek,

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.

Source

pub fn write(&mut self, packet: &CapturedPacket<'_>) -> Result<(), PcapError>

Write a package to the capture file.

Source

pub fn flush(&mut self) -> Result<(), Error>

Flushes the underlying writer.

Source

pub fn take_writer(self) -> W

Destroys this PcapWriter and returns access to the underlying Write.

Source

pub fn get_options(&self) -> WriteOptions

The options used by this PcapWriter.

Auto Trait Implementations§

§

impl<W> Freeze for PcapWriter<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for PcapWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for PcapWriter<W>
where W: Send,

§

impl<W> Sync for PcapWriter<W>
where W: Sync,

§

impl<W> Unpin for PcapWriter<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for PcapWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for PcapWriter<W>
where W: UnwindSafe,

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, 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.