Registry / networking / pnet-datalink

pnet-datalink

JSON →
library0.35.0rscratesunverified

Cross-platform datalink layer networking library for Rust.

# Cargo.toml [dependencies] pnet_datalink = "0.35.0"
INSTALL
IMPORT
SIG · PNET-DATALINK
P
pnet-datalink
networkingrustv0.35.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Channel
use pnet_datalink::Channel;

Opens a datalink channel on the first available network interface.

use pnet_datalink::Channel; fn main() { let interface = pnet_datalink::interfaces().into_iter().next().unwrap(); let (mut tx, mut rx) = match pnet_datalink::channel(&interface, Default::default()) { Ok(Channel::Ethernet(tx, rx)) => (tx, rx), Ok(_) => panic!("unexpected channel type"), Err(e) => panic!("error: {}", e), }; println!("Datalink channel opened on {}", interface.name); }
Debug
Known issues
gotchaRequires root/administrator privileges on most systems to open raw sockets.
fix
Run the binary with sudo (Linux/macOS) or as Administrator (Windows).
affects: >=0.1.0
Upgrade
Version history
0.35.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
pnet-datalink — cargo add pnet-datalink · libregistry