pub struct PcapNgParser { /* private fields */ }
Expand description

Parses a PcapNg from a slice of bytes.

You can match on PcapError::IncompleteBuffer to know if the parser need more data.

Example

use std::fs::File;

use pcap_file::pcapng::PcapNgParser;
use pcap_file::PcapError;

let pcap = std::fs::read("test.pcapng").expect("Error reading file");
let mut src = &pcap[..];

let (rem, mut pcapng_parser) = PcapNgParser::new(src).unwrap();
src = rem;

loop {
    match pcapng_parser.next_block(src) {
        Ok((rem, block)) => {
            // Do something

            // Don't forget to update src
            src = rem;
        },
        Err(PcapError::IncompleteBuffer) => {
            // Load more data into src
        },
        Err(_) => {
            // Handle parsing error
        },
    }
}

Implementations§

Creates a new PcapNgParser.

Parses the first block which must be a valid SectionHeaderBlock.

Returns the remainder and the next Block.

Returns the remainder and the next RawBlock.

Returns the current SectionHeaderBlock.

Returns all the current InterfaceDescriptionBlock.

Returns the InterfaceDescriptionBlock corresponding to the given packet.

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.