Struct smoltcp::iface::SocketSet

source ·
pub struct SocketSet<'a> { /* private fields */ }
Expand description

An extensible set of sockets.

The lifetime 'a is used when storing a Socket<'a>.

Implementations§

source§

impl<'a> SocketSet<'a>

source

pub fn new<SocketsT>(sockets: SocketsT) -> SocketSet<'a>where
SocketsT: Into<ManagedSlice<'a, SocketStorage<'a>>>,

Create a socket set using the provided storage.

source

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.

source

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.

source

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.

source

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.

source

pub fn iter(&self) -> impl Iterator<Item = (SocketHandle, &Socket<'a>)>

Get an iterator to the inner sockets.

source

pub fn iter_mut(
&mut self
) -> impl Iterator<Item = (SocketHandle, &mut Socket<'a>)>

Get a mutable iterator to the inner sockets.

Trait Implementations§

source§

impl<'a> Debug for SocketSet<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for SocketSet<'a>

§

impl<'a> Send for SocketSet<'a>

§

impl<'a> Sync for SocketSet<'a>

§

impl<'a> Unpin for SocketSet<'a>

§

impl<'a> !UnwindSafe for SocketSet<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.