Skip to content

Commit

Permalink
chore(example): add simple example executable (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones authored Nov 17, 2022
1 parent ac6c96e commit 31c4f63
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/show_ip_and_ifs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use local_ip_address::{list_afinet_netifas, local_ip};

fn main() {
match local_ip() {
Ok(ip) => println!("Local IP: {ip}"),
Err(err) => println!("Failed to get local IP: {err}"),
};

match list_afinet_netifas() {
Ok(netifs) => {
println!("Got {} interfaces", netifs.len());
for netif in netifs {
println!("IF: {}, IP: {}", netif.0, netif.1);
}
}
Err(err) => println!("Failed to get list of network interfaces: {err}"),
};
}

0 comments on commit 31c4f63

Please sign in to comment.