pcap-async

Crates.iopcap-async
lib.rspcap-async
version0.2.1
sourcesrc
created_at2019-12-19 02:47:49.655657
updated_at2020-11-12 19:13:22.369358
descriptionAsync/Stream Extensions for libpcap
homepage
repositoryhttps://github.com/dbcfd/pcap-async
max_upload_size
id190464
size68,064
rust-owners (github:protectwise:rust-owners)

documentation

https://docs.rs/pcap-async/

README

pcap-async

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

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

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
pcap-async = "0.1"

Next, add this to your crate:

use futures::StreamExt;
use pcap_async::{Config, Handle, PacketStream};

#[tokio::main]
async fn main() {
    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();
}
Commit count: 99

cargo fmt