sysinfo/
network.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::collections::HashMap;
4
5use crate::network_helper::get_interface_address;
6use crate::NetworkData;
7
8/// Interface addresses are OS-independent
9pub(crate) fn refresh_networks_addresses(interfaces: &mut HashMap<String, NetworkData>) {
10    match get_interface_address() {
11        Ok(ifa_iterator) => {
12            for (name, ifa) in ifa_iterator {
13                if let Some(interface) = interfaces.get_mut(&name) {
14                    interface.mac_addr = ifa;
15                }
16            }
17        }
18        Err(_e) => {
19            sysinfo_debug!("refresh_networks_addresses failed: {:?}", _e);
20        }
21    }
22}