async-pcap
async-pcap is a Rust library that provides an asynchronous wrapper around pcap packet captures. It allows you to capture network packets in a non-blocking, async context using Tokio. Internally, it spawns a dedicated thread to poll packets and delivers them via an asynchronous channel.
Features
- Async-friendly wrapper around
pcap::Capture<Active>. - Returns owned packet data (
Vec<u8>) with packet metadata. - Safe to use in multi-threaded Tokio contexts.
- Simple API:
AsyncCapture::new()andnext_packet().await.
Usage
use ;
use Runtime;
Notes
AsyncCaptureinternally spawns a dedicated thread for polling packets.- Uses a Tokio
MutexandUnboundedReceiverfor async packet delivery. - Suitable for async network monitoring applications.