Просмотр исходного кода

iface: return handle in sockets/sockets_mut.

Dario Nieuwenhuis 3 лет назад
Родитель
Сommit
8a3aaa12d1
1 измененных файлов с 6 добавлено и 4 удалено
  1. 6 4
      src/iface/interface.rs

+ 6 - 4
src/iface/interface.rs

@@ -556,13 +556,15 @@ where
     }
 
     /// Get an iterator to the inner sockets.
-    pub fn sockets(&self) -> impl Iterator<Item = &Socket<'a>> {
-        self.sockets.iter().map(|i| &i.socket)
+    pub fn sockets(&self) -> impl Iterator<Item = (SocketHandle, &Socket<'a>)> {
+        self.sockets.iter().map(|i| (i.meta.handle, &i.socket))
     }
 
     /// Get a mutable iterator to the inner sockets.
-    pub fn sockets_mut(&mut self) -> impl Iterator<Item = &mut Socket<'a>> {
-        self.sockets.iter_mut().map(|i| &mut i.socket)
+    pub fn sockets_mut(&mut self) -> impl Iterator<Item = (SocketHandle, &mut Socket<'a>)> {
+        self.sockets
+            .iter_mut()
+            .map(|i| (i.meta.handle, &mut i.socket))
     }
 
     /// Add an address to a list of subscribed multicast IP addresses.