Skip to content

Commit 1a28ef5

Browse files
committed
Expose self.sockets in Interface via iterators
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.
1 parent 29d0fcc commit 1a28ef5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/iface/interface.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,16 @@ where
555555
&mut self.device
556556
}
557557

558+
/// Get an iterator to the inner sockets.
559+
pub fn sockets(&self) -> impl Iterator<Item = &Socket<'a>> {
560+
self.sockets.iter()
561+
}
562+
563+
/// Get a mutable iterator to the inner sockets.
564+
pub fn sockets_mut(&mut self) -> impl Iterator<Item = &mut Socket<'a>> {
565+
self.sockets.iter_mut()
566+
}
567+
558568
/// Add an address to a list of subscribed multicast IP addresses.
559569
///
560570
/// Returns `Ok(announce_sent)` if the address was added successfully, where `annouce_sent`

0 commit comments

Comments
 (0)