[−][src]Struct pcap_file::PcapParser
Parser for a Pcap formated stream.
Examples
use pcap_file::pcap::PcapParser; use pcap_file::PcapError; let pcap = vec![0_u8; 0]; let mut src = &pcap[..]; // Creates a new parser and parse the pcap header let (rem, pcap_parser) = PcapParser::new(&pcap[..]).unwrap(); src = rem; loop { match pcap_parser.next_packet(src) { Ok((rem, packet)) => { // 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 PcapParser
[src]
pub fn new(slice: &[u8]) -> Result<(&[u8], PcapParser), PcapError>
[src]
Creates a new PcapParser
.
Returns the parser and the remainder.
pub fn next_packet<'a>(
&self,
slice: &'a [u8]
) -> Result<(&'a [u8], Packet<'a>), PcapError>
[src]
&self,
slice: &'a [u8]
) -> Result<(&'a [u8], Packet<'a>), PcapError>
Returns the next packet and the remainder.
Trait Implementations
Auto Trait Implementations
impl Send for PcapParser
impl Sync for PcapParser
impl Unpin for PcapParser
impl UnwindSafe for PcapParser
impl RefUnwindSafe for PcapParser
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,