Struct pcap_file::pcapng::PcapNgReader
source · pub struct PcapNgReader<R: Read> { /* private fields */ }
Expand description
Reads a PcapNg from a reader.
Example
use std::fs::File;
use pcap_file::pcapng::PcapNgReader;
let file_in = File::open("test.pcapng").expect("Error opening file");
let mut pcapng_reader = PcapNgReader::new(file_in).unwrap();
// Read test.pcapng
while let Some(block) = pcapng_reader.next_block() {
//Check if there is no error
let block = block.unwrap();
//Do something
}
Implementations§
source§impl<R: Read> PcapNgReader<R>
impl<R: Read> PcapNgReader<R>
sourcepub fn new(reader: R) -> Result<PcapNgReader<R>, PcapError>
pub fn new(reader: R) -> Result<PcapNgReader<R>, PcapError>
Creates a new PcapNgReader
from a reader.
Parses the first block which must be a valid SectionHeaderBlock.
sourcepub fn next_raw_block(&mut self) -> Option<Result<RawBlock<'_>, PcapError>>
pub fn next_raw_block(&mut self) -> Option<Result<RawBlock<'_>, PcapError>>
Returns the next RawBlock
.
sourcepub fn section(&self) -> &SectionHeaderBlock<'static>
pub fn section(&self) -> &SectionHeaderBlock<'static>
Returns the current SectionHeaderBlock
.
sourcepub fn interfaces(&self) -> &[InterfaceDescriptionBlock<'static>]
pub fn interfaces(&self) -> &[InterfaceDescriptionBlock<'static>]
Returns all the current InterfaceDescriptionBlock
.
sourcepub fn packet_interface(
&self,
packet: &EnhancedPacketBlock<'_>
) -> Option<&InterfaceDescriptionBlock<'_>>
pub fn packet_interface(
&self,
packet: &EnhancedPacketBlock<'_>
) -> Option<&InterfaceDescriptionBlock<'_>>
Returns the InterfaceDescriptionBlock
corresponding to the given packet
sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes the Self
, returning the wrapped reader.