From 0fa98895ae4e6f50f345e7cb17717b5d9914f67b Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Sat, 13 Nov 2021 16:36:22 +0900 Subject: [PATCH] Update README.md --- README.md | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 35dd44c..3c02341 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Get default network information Add `default-net` to your dependencies ```toml:Cargo.toml [dependencies] -default-net = "0.4.0" +default-net = "0.5.0" ``` ## Example @@ -23,16 +23,29 @@ default-net = "0.4.0" use default_net; fn main(){ - if let Some(default_interface) = default_net::get_default_interface(){ - println!("Index {}", default_interface.index); - println!("Name {}", default_interface.name); - println!("MAC {:?}", default_interface.mac); - println!("IPv4 {:?}", default_interface.ipv4); - println!("IPv6 {:?}", default_interface.ipv6); - println!("Gateway IP {:?}", default_interface.gateway.ip); - println!("Gateway MAC {:?}", default_interface.gateway.mac); - }else{ - println!("Failed to get default interface info"); + match default_net::get_default_interface() { + Ok(default_interface) => { + println!("Default Interface"); + println!("\tIndex: {}", default_interface.index); + println!("\tName: {}", default_interface.name); + if let Some(mac_addr) = default_interface.mac_addr { + println!("\tMAC: {}", mac_addr); + }else{ + println!("\tMAC: (Failed to get mac address)"); + } + println!("\tIPv4: {:?}", default_interface.ipv4); + println!("\tIPv6: {:?}", default_interface.ipv6); + if let Some(gateway) = default_interface.gateway { + println!("Default Gateway"); + println!("\tMAC: {}", gateway.mac_addr); + println!("\tIP: {}", gateway.ip_addr); + }else { + println!("Default Gateway: (Not found)"); + } + }, + Err(e) => { + println!("{}", e); + }, } } ```