default-net 0.22.0

Cross-platform library for network interface and gateway
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 default_net::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);
        }
    }
}