SocketSet

Struct SocketSet 

Source
pub struct SocketSet<const TIMER_HZ: u32, const N: usize, const L: usize> {
    pub sockets: Vec<Option<Socket<TIMER_HZ, L>>, N>,
}
Expand description

An extensible set of sockets.

Fields§

§sockets: Vec<Option<Socket<TIMER_HZ, L>>, N>

Implementations§

Source§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Set<TIMER_HZ, N, L>

Source

pub fn new() -> Set<TIMER_HZ, N, L>

Create a socket set using the provided storage.

Source

pub fn capacity(&self) -> usize

Get the maximum number of sockets the set can hold

Source

pub fn len(&self) -> usize

Get the current number of initialized sockets, the set is holding

Source

pub fn is_empty(&self) -> bool

Check if the set is currently holding no active sockets

Source

pub fn socket_type(&self, handle: Handle) -> Option<SocketType>

Get the type of a specific socket in the set.

Returned as a SocketType

Source

pub fn add<T>(&mut self, socket: T) -> Result<Handle, Error>
where T: Into<Socket<TIMER_HZ, L>>,

Add a socket to the set with the reference count 1, and return its handle.

Source

pub fn get<T: AnySocket<TIMER_HZ, L>>( &mut self, handle: Handle, ) -> Result<SocketRef<'_, T>, Error>

Get a socket from the set by its handle, as mutable.

Source

pub fn remove(&mut self, handle: Handle) -> Result<(), Error>

Remove a socket from the set

Source

pub fn prune(&mut self)

Prune the sockets in this set.

All sockets are removed and dropped.

Source

pub fn recycle(&mut self, ts: Instant<TIMER_HZ>) -> bool

Source

pub fn iter(&self) -> impl Iterator<Item = (Handle, &Socket<TIMER_HZ, L>)>

Iterate every socket in this set.

Source

pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (Handle, SocketRef<'_, Socket<TIMER_HZ, L>>)>

Iterate every socket in this set, as SocketRef.

Trait Implementations§

Source§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Debug for Set<TIMER_HZ, N, L>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Default for Set<TIMER_HZ, N, L>

Source§

fn default() -> Set<TIMER_HZ, N, L>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Freeze for Set<TIMER_HZ, N, L>

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> RefUnwindSafe for Set<TIMER_HZ, N, L>

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Send for Set<TIMER_HZ, N, L>

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Sync for Set<TIMER_HZ, N, L>

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> Unpin for Set<TIMER_HZ, N, L>

§

impl<const TIMER_HZ: u32, const N: usize, const L: usize> UnwindSafe for Set<TIMER_HZ, N, L>

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> Same for T

Source§

type Output = T

Should always be Self
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.