smoltcp::iface

Struct 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>. If you’re using owned buffers for your sockets (passed in as Vecs) you can use SocketSet<'static>.

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> Freeze for SocketSet<'a>

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.