14个不稳定版本 (3个破坏性版本)

0.4.1 2020年9月30日
0.3.0 2020年7月2日
0.2.1 2020年11月12日
0.1.5 2020年3月29日
0.1.3 2019年12月19日

#1797 in 异步

MIT授权

62KB
1.5K SLoC

pcap-async

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

Rust对pcap-sys的异步封装。使用Futures 0.3Smol

文档

使用方法

首先,将以下内容添加到您的Cargo.toml

[dependencies]
pcap-async = "0.3"

然后,将以下内容添加到您的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();
    })
}

依赖项

~9–21MB
~273K SLoC