netdev 0.41.0

Cross-platform library for enumerating network interfaces with metadata.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// This example shows how to use serde feature to serialize the default network interface to JSON.
fn main() {
    match netdev::get_default_interface() {
        Ok(interface) => match serde_json::to_string_pretty(&interface) {
            Ok(json) => {
                println!("{}", json);
            }
            Err(e) => {
                println!("Serialization Error: {}", e);
            }
        },
        Err(e) => {
            println!("Error: {}", e);
        }
    }
}