Test
Test

Reputation: 1720

Rust crate module error - module not found when documented in library

How does one determine the modules available in a rust crate?

I'm trying to follow the example here:

use pcap_parser::data::{get_packetdata, PacketData};
use pcap_parser::pcapng::EnhancedPacketBlock;
use pcap_parser::Linktype;

However, the exact same example gives an error even when I'm using the same version of the library (0.13.1):

(base) w@ws-MacBook-Air rust % cargo build
   Compiling rust v0.1.0 (/Users/w/Dropbox/Codin/iex/rust)
error[E0432]: unresolved import `pcap_parser::data`
 --> src/main.rs:2:18
  |
2 | use pcap_parser::data::{get_packetdata, PacketData};
  |                  ^^^^ could not find `data` in `pcap_parser`

How can this be? What am I doing wrong?

Minimal reproducible example:

main.rs:

use pcap_parser::data::{get_packetdata, PacketData};

fn main() {
    println!("Minimal example");
}

Cargo.toml:

[package]
name = "rust"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
pcap-parser = "0.13.1"
flate2 = "1.0.22"

Upvotes: 0

Views: 353

Answers (1)

cdhowie
cdhowie

Reputation: 168948

You need to enable the "data" feature to use this module:

pcap-parser = { version = "0.13.1", features = ["data"] }

Upvotes: 1

Related Questions