pub struct AsyncCapture { /* private fields */ }Expand description
An asynchronous wrapper around a pcap::Capture.
AsyncCapture owns the receiver side of a channel that receives
captured packets or a stop signal. It allows async code to
await new packets without blocking a thread.
Implementations§
Source§impl AsyncCapture
impl AsyncCapture
Sourcepub fn new(cap: Capture<Active>) -> (Self, AsyncCaptureHandle)
pub fn new(cap: Capture<Active>) -> (Self, AsyncCaptureHandle)
Creates a new asynchronous capture from a pcap::Capture<Active>.
Spawns a background thread that reads packets and sends them through a channel for async consumption.
Returns a tuple of (AsyncCapture, AsyncCaptureHandle).
Sourcepub async fn next_packet(&self) -> Option<Packet>
pub async fn next_packet(&self) -> Option<Packet>
Waits for the next packet asynchronously.
Returns Some(Packet) if a packet is received,
or None if the capture has stopped.
Auto Trait Implementations§
impl !Freeze for AsyncCapture
impl !RefUnwindSafe for AsyncCapture
impl Send for AsyncCapture
impl Sync for AsyncCapture
impl Unpin for AsyncCapture
impl !UnwindSafe for AsyncCapture
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more