pub struct SocketSet<'a> { /* private fields */ }
Expand description
An extensible set of sockets.
The lifetime 'a
is used when storing a Socket<'a>
. If you’re using
owned buffers for your sockets (passed in as Vec
s) you can use
SocketSet<'static>
.
Implementations§
Source§impl<'a> SocketSet<'a>
impl<'a> SocketSet<'a>
Sourcepub fn new<SocketsT>(sockets: SocketsT) -> SocketSet<'a>
pub fn new<SocketsT>(sockets: SocketsT) -> SocketSet<'a>
Create a socket set using the provided storage.
Sourcepub fn add<T: AnySocket<'a>>(&mut self, socket: T) -> SocketHandle
pub fn add<T: AnySocket<'a>>(&mut self, socket: T) -> SocketHandle
Add a socket to the set, and return its handle.
§Panics
This function panics if the storage is fixed-size (not a Vec
) and is full.
Sourcepub fn get<T: AnySocket<'a>>(&self, handle: SocketHandle) -> &T
pub fn get<T: AnySocket<'a>>(&self, handle: SocketHandle) -> &T
Get a socket from the set by its handle, as mutable.
§Panics
This function may panic if the handle does not belong to this socket set or the socket has the wrong type.
Sourcepub fn get_mut<T: AnySocket<'a>>(&mut self, handle: SocketHandle) -> &mut T
pub fn get_mut<T: AnySocket<'a>>(&mut self, handle: SocketHandle) -> &mut T
Get a mutable socket from the set by its handle, as mutable.
§Panics
This function may panic if the handle does not belong to this socket set or the socket has the wrong type.
Sourcepub fn remove(&mut self, handle: SocketHandle) -> Socket<'a>
pub fn remove(&mut self, handle: SocketHandle) -> Socket<'a>
Remove a socket from the set, without changing its state.
§Panics
This function may panic if the handle does not belong to this socket set.
Sourcepub fn iter(&self) -> impl Iterator<Item = (SocketHandle, &Socket<'a>)>
pub fn iter(&self) -> impl Iterator<Item = (SocketHandle, &Socket<'a>)>
Get an iterator to the inner sockets.
Sourcepub fn iter_mut(
&mut self,
) -> impl Iterator<Item = (SocketHandle, &mut Socket<'a>)>
pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (SocketHandle, &mut Socket<'a>)>
Get a mutable iterator to the inner sockets.