pub struct RtnlLinkClient { /* private fields */ }Implementations§
Source§impl RtnlLinkClient
impl RtnlLinkClient
pub fn interface_get_by_name(&self, name: &str) -> Result<Interface>
Sourcepub fn mac_addr_get(&self, if_id: u32) -> Result<Option<MacAddr>>
pub fn mac_addr_get(&self, if_id: u32) -> Result<Option<MacAddr>>
Examples found in repository?
examples/if-summary.rs (line 12)
4fn main() -> std::io::Result<()> {
5 let client = RtnlClient::new();
6 let link_client = client.link();
7 let addr_client = client.address();
8 let ifs = link_client.interface_list()?;
9 for interface in ifs {
10 println!("Interface: {} ({})", &interface.if_name, interface.if_id);
11 let if_id = interface.if_id;
12 let mac = link_client.mac_addr_get(if_id)?;
13 if let Some(mac) = mac {
14 println!(" MAC address: {}", mac);
15 } else {
16 println!(" No MAC address");
17 }
18 let v4addrs = addr_client.ipv4_addrs_get(Some(if_id))?;
19 println!(" IPv4 addresses:");
20 for addr in v4addrs {
21 println!(" {}", addr);
22 }
23 let v6addrs = addr_client.ipv6_addrs_get(Some(if_id))?;
24 println!(" IPv6 addresses:");
25 for addr in v6addrs {
26 println!(" {}", addr);
27 }
28 println!("");
29 }
30 Ok(())
31}Sourcepub fn interface_list(&self) -> Result<Vec<Interface>>
pub fn interface_list(&self) -> Result<Vec<Interface>>
Examples found in repository?
examples/if-summary.rs (line 8)
4fn main() -> std::io::Result<()> {
5 let client = RtnlClient::new();
6 let link_client = client.link();
7 let addr_client = client.address();
8 let ifs = link_client.interface_list()?;
9 for interface in ifs {
10 println!("Interface: {} ({})", &interface.if_name, interface.if_id);
11 let if_id = interface.if_id;
12 let mac = link_client.mac_addr_get(if_id)?;
13 if let Some(mac) = mac {
14 println!(" MAC address: {}", mac);
15 } else {
16 println!(" No MAC address");
17 }
18 let v4addrs = addr_client.ipv4_addrs_get(Some(if_id))?;
19 println!(" IPv4 addresses:");
20 for addr in v4addrs {
21 println!(" {}", addr);
22 }
23 let v6addrs = addr_client.ipv6_addrs_get(Some(if_id))?;
24 println!(" IPv6 addresses:");
25 for addr in v6addrs {
26 println!(" {}", addr);
27 }
28 println!("");
29 }
30 Ok(())
31}Trait Implementations§
Source§impl Clone for RtnlLinkClient
impl Clone for RtnlLinkClient
Source§fn clone(&self) -> RtnlLinkClient
fn clone(&self) -> RtnlLinkClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RtnlLinkClient
impl Debug for RtnlLinkClient
Source§impl Hash for RtnlLinkClient
impl Hash for RtnlLinkClient
Source§impl PartialEq for RtnlLinkClient
impl PartialEq for RtnlLinkClient
impl Eq for RtnlLinkClient
impl StructuralPartialEq for RtnlLinkClient
Auto Trait Implementations§
impl Freeze for RtnlLinkClient
impl RefUnwindSafe for RtnlLinkClient
impl Send for RtnlLinkClient
impl Sync for RtnlLinkClient
impl Unpin for RtnlLinkClient
impl UnwindSafe for RtnlLinkClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more