소스 검색

Merge #568

568: Expose `self.sockets` in `Interface` r=Dirbaio a=korken89

This is needed to not loose access to methods on sockets, e.g. iterating
over them and closing or checking which ports are being used.

Not sure if there is some other way this is meant to be done.

Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
bors[bot] 3 년 전
부모
커밋
8e6fc7fec8
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      src/iface/interface.rs

+ 10 - 0
src/iface/interface.rs

@@ -555,6 +555,16 @@ where
         &mut self.device
     }
 
+    /// Get an iterator to the inner sockets.
+    pub fn sockets(&self) -> impl Iterator<Item = &Socket<'a>> {
+        self.sockets.iter()
+    }
+
+    /// Get a mutable iterator to the inner sockets.
+    pub fn sockets_mut(&mut self) -> impl Iterator<Item = &mut Socket<'a>> {
+        self.sockets.iter_mut()
+    }
+
     /// Add an address to a list of subscribed multicast IP addresses.
     ///
     /// Returns `Ok(announce_sent)` if the address was added successfully, where `annouce_sent`