[][src]Struct pcarp::Capture

pub struct Capture<R> { /* fields omitted */ }

A packet capture which can be iterated over.

There are two APIs here:

  • Iterator style: next
  • Streaming-iterator style: advance/get

The streaming iterator API is slightly more general when the items are borrowed. I expect that most users will just use next(), but users needing to work around lifetime contraints may need to use advance/get. Nothing bad will happen if you mix these two APIs.

Methods

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

pub fn new(rdr: R) -> Result<Capture<R>, Error>[src]

Create a new Capture.

pub fn next<'a, 'b>(&'a mut self) -> Option<Result<Packet<'b>, Error>> where
    'a: 'b, 
[src]

Get the next packet.

This function is a wrapper around the lower-level API: it simply calls advance() then get().

pub fn advance(&mut self) -> Result<(), Error>[src]

Parse the next packet from the pcap file.

This function parses the packet but doesn't return it. Use get() to see the results.

pub fn get(&self) -> Option<Packet>[src]

Peek the current packet.

This function is cheap, since Packet holds a reference to the internal buffer and no pcap data is copied. When you're done with this packet and want to see the next one, use advance() to move on.

impl<R: Read + Seek> Capture<R>[src]

pub fn rewind(&mut self) -> Result<(), Error>[src]

Rewind to the beginning of the pcapng file

Auto Trait Implementations

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

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

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

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

impl<R> RefUnwindSafe for Capture<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<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]