Struct pcap_file::pcap::PcapReader

source ·
pub struct PcapReader<R: Read> { /* private fields */ }
Expand description

Reads a pcap from a reader.

Example

use std::fs::File;

use pcap_file::pcap::PcapReader;

let file_in = File::open("test.pcap").expect("Error opening file");
let mut pcap_reader = PcapReader::new(file_in).unwrap();

// Read test.pcap
while let Some(pkt) = pcap_reader.next_packet() {
    //Check if there is no error
    let pkt = pkt.unwrap();

    //Do something
}

Implementations§

Creates a new PcapReader from an existing reader.

This function reads the global pcap header of the file to verify its integrity.

The underlying reader must point to a valid pcap file/stream.

Errors

The data stream is not in a valid pcap file format.

The underlying data are not readable.

Consumes Self, returning the wrapped reader.

Returns the next PcapPacket.

Returns the next RawPcapPacket.

Returns the global header of the pcap.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.