[][src]Struct pcap_file::pcapng::PcapNgReader

pub struct PcapNgReader<R: Read> { /* fields omitted */ }

Wraps another reader and uses it to read a PcapNg formated stream.

It implements the Iterator trait in order to read one block at a time except the first SectionHeaderBlock

Examples

use std::fs::File;
use pcap_file::pcapng::PcapNgReader;

let file_in = File::open("test.pcapng").expect("Error opening file");
let pcapng_reader = PcapNgReader::new(file_in).unwrap();

// Read test.pcapng
for block in pcapng_reader {

    //Check if there is no error
    let block = block.unwrap();

    //Parse block content
    let parsed_block = block.parsed().unwrap();

    //Do something
}

Methods

impl<R: Read> PcapNgReader<R>[src]

pub fn new(reader: R) -> Result<PcapNgReader<R>, PcapError>[src]

Creates a new PcapNgReader from a reader. Parses the first block which must be a valid SectionHeaderBlock

pub fn section(&self) -> &SectionHeaderBlock<'static>[src]

Returns the current SectionHeaderBlock

pub fn interfaces(&self) -> &[InterfaceDescriptionBlock<'static>][src]

Returns the current interfaces

pub fn packet_interface(
    &self,
    packet: &EnhancedPacketBlock
) -> Option<&InterfaceDescriptionBlock>
[src]

Returns the InterfaceDescriptionBlock corresponding to the given packet

Trait Implementations

impl<R: Read> Iterator for PcapNgReader<R>[src]

type Item = Result<Block<'static>, PcapError>

The type of the elements being iterated over.

Auto Trait Implementations

impl<R> Send for PcapNgReader<R> where
    R: Send

impl<R> Sync for PcapNgReader<R> where
    R: Sync

impl<R> Unpin for PcapNgReader<R> where
    R: Unpin

impl<R> UnwindSafe for PcapNgReader<R> where
    R: UnwindSafe

impl<R> RefUnwindSafe for PcapNgReader<R> where
    R: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]