14 unstable releases (3 breaking)

0.4.1 Sep 30, 2020
0.3.0 Jul 2, 2020
0.2.1 Nov 12, 2020
0.1.5 Mar 29, 2020
0.1.3 Dec 19, 2019

#644 in Asynchronous

Download history 161/week @ 2024-11-15 208/week @ 2024-11-22 301/week @ 2024-11-29 851/week @ 2024-12-06 664/week @ 2024-12-13 249/week @ 2024-12-20 169/week @ 2024-12-27 651/week @ 2025-01-03 628/week @ 2025-01-10 578/week @ 2025-01-17 680/week @ 2025-01-24 381/week @ 2025-01-31 446/week @ 2025-02-07 520/week @ 2025-02-14 510/week @ 2025-02-21 440/week @ 2025-02-28

1,976 downloads per month

MIT license

62KB
1.5K SLoC

pcap-async

build status crates.io version docs.rs docs MIT licensed

Rust async wrapper around pcap-sys. Utilizes Futures 0.3 and Smol.

Documentation

Usage

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};

fn main() {
    smol::run(async move {
        let handle = Handle::lookup().expect("No handle created");
        let mut provider = PacketStream::new(Config::default(), handle)
            .expect("Could not create provider")
            .fuse();
        while let Some(packets) = provider.next().await {
    
        }
        handle.interrupt();
    })
}

Dependencies

~8–22MB
~272K SLoC