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.
Auto Trait Implementations§
impl<R> Freeze for PcapNgReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for PcapNgReader<R>where
R: RefUnwindSafe,
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,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more