Преглед изворни кода

DnsSocket: Be able to update servers

Emil Fresk пре 2 година
родитељ
комит
bf620615f9
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      src/socket/dns.rs

+ 8 - 0
src/socket/dns.rs

@@ -78,6 +78,14 @@ impl<'a> DnsSocket<'a> {
         }
     }
 
+    /// Update the managed slice with servers
+    pub fn update_servers(&mut self, servers: &[IpAddress]) {
+        self.servers
+            .iter_mut()
+            .zip(servers.iter())
+            .for_each(|(a, b)| *a = *b);
+    }
+
     /// Return the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.
     ///
     /// See also the [set_hop_limit](#method.set_hop_limit) method