Skip to main content

PacketCapture

Struct PacketCapture 

Source
pub struct PacketCapture { /* private fields */ }
Expand description

Records all traffic in memory via WireTap.

Use drain to retrieve and clear the buffer. For bounded capture with automatic eviction, see RingBufferCapture.

Prefer BusCapture for new code — it includes built-in statistics counters.

Implementations§

Source§

impl PacketCapture

Source

pub fn new() -> Self

Create an empty packet capture buffer.

Source

pub fn drain(&self) -> Vec<PacketRecord>

Retrieve and clear all captured records.

Source

pub fn len(&self) -> usize

Number of recorded packets.

Source

pub fn is_empty(&self) -> bool

Returns true if no packets have been recorded.

Trait Implementations§

Source§

impl Default for PacketCapture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl WireTap for PacketCapture

Source§

fn on_write(&self, bytes: &[u8], ts: u64)

Bytes successfully written to the transport. Called once per poll_write that returns Ok(n) with n > 0.
Source§

fn on_read(&self, bytes: &[u8], ts: u64)

Bytes successfully read from the transport. Called once per poll_read that returns Ready(Ok(())) with new data.
Source§

fn on_error(&self, bytes: &[u8], error: &str, ts: u64)

Read returned an error, but partial data may have been received. Called when poll_read returns Ready(Err(e)) and the read buffer contains bytes that arrived before the error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.