Struct PacketCapture

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

Basic PacketCapture type

Marker as PhantomData allow compile-time checking of struct use

Implementations§

Source§

impl PacketCapture<Uninitialized>

Uninitialized PacketCaptures can be created only

Source

pub fn new_from_interface( interface_name: &str, ) -> Result<PacketCapture<Initialized>, Box<dyn Error>>

Create a PacketCapture

Takes an interface name and returns an Initialized PacketCapture

Source

pub fn new_with_default() -> Result<PacketCapture<Initialized>, Box<dyn Error>>

Create a PacketCapture

Returns an Initialized PacketCapture with the default interface

Source§

impl PacketCapture<Initialized>

Initialized PacketCaptures can start a capture or a live processing callback

Source

pub fn start_capture(&self) -> PacketCapture<Started>

Start capturing

Stores packets that can be accessed later with the results methods

Source

pub fn start_live_process( &self, callback: impl FnMut(Vec<u8>) + Send + 'static, ) -> PacketCapture<Started>

Start live processing

Takes (and calls) a callback function on incoming streams of bytes

Source§

impl PacketCapture<Started>

Started PacketCaptures can stop only

Source

pub fn stop_capture(&self) -> PacketCapture<Completed>

Stop capturing

Not much more to it

Source§

impl PacketCapture<Completed>

Completed PacketCaptures return results in various formats

Source

pub fn results_raw(&self) -> Arc<[Vec<u8>]>

Results returned as raw vectors of bytes

Source

pub fn results_as_ethernet(&self) -> EthernetFrameCollection<'_>

Results returned as ethernet frames

Source

pub fn results_as_ipv4(&self) -> Ipv4PacketCollection<'_>

Results returned as ipv4 packets

Source

pub fn results_as_tcp(&self) -> TcpSegmentCollection<'_>

Results returned as tcp segments

Trait Implementations§

Source§

impl<State: Debug> Debug for PacketCapture<State>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<State> Freeze for PacketCapture<State>

§

impl<State> RefUnwindSafe for PacketCapture<State>
where State: RefUnwindSafe,

§

impl<State> Send for PacketCapture<State>
where State: Send,

§

impl<State> Sync for PacketCapture<State>
where State: Sync,

§

impl<State> Unpin for PacketCapture<State>
where State: Unpin,

§

impl<State> UnwindSafe for PacketCapture<State>
where State: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.