Skip to content

Commit

Permalink
Expose self.sockets in Interface via iterators
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
korken89 committed Nov 14, 2021
1 parent 29d0fcc commit 1a28ef5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/iface/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 1a28ef5

Please sign in to comment.