[−][src]Struct pcap_file::pcapng::PcapNgParser
Parser for a PcapNg formated stream.
You can match on PcapError::IncompleteBuffer to known if the parser need more data
Examples
use std::fs::File; use pcap_file::pcapng::PcapNgParser; use pcap_file::PcapError; let data = vec![0_8;100]; let mut src = &data[..]; let (rem, mut pcapng_parser) = PcapNgParser::new(src).unwrap(); src = rem; loop { match pcapng_parser.next_block(src) { Ok((rem, block)) => { //Parse block content let parsed_block = block.parsed().unwrap(); // Do something // Don't forget to update src src = rem; // No more data, if no more incoming either then this is the end of the file if rem.is_empty() { break; } }, Err(PcapError::IncompleteBuffer(needed)) => {},// Load more data into src Err(_) => {}// Parsing error } }
Methods
impl PcapNgParser
[src]
pub fn new(src: &[u8]) -> Result<(&[u8], Self), PcapError>
[src]
Creates a new PcapNgParser
.
Parses the first block which must be a valid SectionHeaderBlock
pub fn next_block<'a>(
&mut self,
src: &'a [u8]
) -> Result<(&'a [u8], Block<'a>), PcapError>
[src]
&mut self,
src: &'a [u8]
) -> Result<(&'a [u8], Block<'a>), PcapError>
Returns the remainder and the next block
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]
&self,
packet: &EnhancedPacketBlock
) -> Option<&InterfaceDescriptionBlock>
Returns the InterfaceDescriptionBlock corresponding to the given packet
Auto Trait Implementations
impl Send for PcapNgParser
impl Sync for PcapNgParser
impl Unpin for PcapNgParser
impl UnwindSafe for PcapNgParser
impl RefUnwindSafe for PcapNgParser
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,