Rust async wrapper around pcap-sys. Utilizes Futures 0.3 and Smol.
First, add this to your Cargo.toml:
[dependencies]
pcap-async = "0.3"Next, add this to your crate:
use futures::StreamExt;use pcap_async::{Config,Handle,PacketStream};fnmain(){
smol::run(asyncmove{let handle = Handle::lookup().expect("No handle created");letmut provider = PacketStream::new(Config::default(), handle).expect("Could not create provider").fuse();whileletSome(packets) = provider.next().await{}
handle.interrupt();})}