瀏覽代碼

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