]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
pnet: use a NetworkView type alias to reduce redundancy
authorYann Dirson <yann.dirson@vates.fr>
Mon, 20 Nov 2023 14:52:07 +0000 (15:52 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Fri, 8 Dec 2023 09:59:46 +0000 (10:59 +0100)
Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
src/collector_net_pnet.rs

index 23b99db4cdefc222303da736f35339cdfd7a8372..97de8f5edac0239c8a7e258c618b9807f317dd78 100644 (file)
@@ -15,8 +15,9 @@ enum Address {
     IP(IpNetwork),
     MAC(MacAddr),
 }
+type NetworkView = HashMap<String, HashSet<Address>>;
 pub struct NetworkSource {
-    cache: HashMap<String, HashSet<Address>>,
+    cache: NetworkView,
 }
 
 impl NetworkSource {
@@ -45,7 +46,7 @@ impl NetworkSource {
         let network_interfaces = pnet_datalink::interfaces();
 
         // get a full view of interfaces, diffable with the cache
-        let mut network_view: HashMap<String, HashSet<Address>> = HashMap::new();
+        let mut network_view: NetworkView = HashMap::new();
         for iface in network_interfaces.iter() {
             // KLUDGE: drop ":alias" suffix for Linux interface aliases
             let name = iface.name.split(":").next().unwrap_or(&iface.name);