[−][src]Trait pcap_parser::traits::PcapReaderIterator
Iterator over pcap files
Each call to next
will return the next block,
and must be followed by call to consume
to avoid reading the same data.
consume
takes care of refilling the buffer.
It is possible to read multiple blocks before consuming data.
Call consume_noshift
instead of consume
. To refill the buffer, first ensures that you do
not keep any reference over internal data (blocks or slices), and call refill
.
To determine when a refill is needed, either test next()
for an incomplete read. You can also
use position
to implement a heuristic refill (for ex, when positon > capacity / 2
.
The blocks already read, and underlying data, must be discarded before calling
consume
or refill
. It is the caller's responsibility to call functions in the correct
order.
Required methods
fn next(&mut self) -> Result<(usize, PcapBlockOwned), PcapError>
Get the next pcap block, if possible. Returns the number of bytes read and the block.
fn consume(&mut self, offset: usize)
Consume data, and refill buffer if needed.
The blocks already read, and underlying data, must be discarded before calling this function.
fn consume_noshift(&mut self, offset: usize)
Consume date, but do not change the buffer. Blocks already read are still valid.
fn refill(&mut self) -> Result<(), PcapError>
Refill the internal buffer, shifting it if necessary.
The blocks already read, and underlying data, must be discarded before calling this function.
fn position(&self) -> usize
Get the position in the internal buffer. Can be used to determine if refill
is required.
fn grow(&mut self, new_size: usize) -> bool
Grow size of the internal buffer.
fn data(&self) -> &[u8]
Returns a slice with all the available data
Implementors
impl<R> PcapReaderIterator<R> for LegacyPcapReader<R> where
R: Read,
[src]
R: Read,
fn next(&mut self) -> Result<(usize, PcapBlockOwned), PcapError>
[src]
fn consume(&mut self, offset: usize)
[src]
fn consume_noshift(&mut self, offset: usize)
[src]
fn refill(&mut self) -> Result<(), PcapError>
[src]
fn position(&self) -> usize
[src]
fn grow(&mut self, new_size: usize) -> bool
[src]
fn data(&self) -> &[u8]
[src]
impl<R> PcapReaderIterator<R> for PcapNGReader<R> where
R: Read,
[src]
R: Read,