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

#695 in Asynchronous

Download history 242/week @ 2024-07-19 294/week @ 2024-07-26 200/week @ 2024-08-02 155/week @ 2024-08-09 173/week @ 2024-08-16 185/week @ 2024-08-23 168/week @ 2024-08-30 126/week @ 2024-09-06 3/week @ 2024-09-13 21/week @ 2024-09-20 19/week @ 2024-09-27 18/week @ 2024-10-04 11/week @ 2024-10-11 17/week @ 2024-10-18 122/week @ 2024-10-25 165/week @ 2024-11-01

319 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

~9–22MB
~277K SLoC