netstack3_base::socket

Trait SocketMapAddrStateSpec

Source
pub trait SocketMapAddrStateSpec {
    type Id;
    type SharingState;
    type Inserter<'a>: Inserter<Self::Id> + 'a
       where Self: 'a,
             Self::Id: 'a;

    // Required methods
    fn new(new_sharing_state: &Self::SharingState, id: Self::Id) -> Self;
    fn contains_id(&self, id: &Self::Id) -> bool;
    fn try_get_inserter<'a, 'b>(
        &'b mut self,
        new_sharing_state: &'a Self::SharingState,
    ) -> Result<Self::Inserter<'b>, IncompatibleError>;
    fn could_insert(
        &self,
        new_sharing_state: &Self::SharingState,
    ) -> Result<(), IncompatibleError>;
    fn remove_by_id(&mut self, id: Self::Id) -> RemoveResult;
}
Expand description

Describes an entry in a SocketMap for a listener or connection address.

Required Associated Types§

Source

type Id

The type of ID that can be present at the address.

Source

type SharingState

The sharing state for the address.

This can be used to determine whether a socket can be inserted at the address. Every socket has its own sharing state associated with it, though the sharing state is not necessarily stored in the address entry.

Source

type Inserter<'a>: Inserter<Self::Id> + 'a where Self: 'a, Self::Id: 'a

The type of inserter returned by SocketMapAddrStateSpec::try_get_inserter.

Required Methods§

Source

fn new(new_sharing_state: &Self::SharingState, id: Self::Id) -> Self

Creates a new Self holding the provided socket with the given new sharing state at the specified address.

Source

fn contains_id(&self, id: &Self::Id) -> bool

Looks up the ID in self, returning true if it is present.

Source

fn try_get_inserter<'a, 'b>( &'b mut self, new_sharing_state: &'a Self::SharingState, ) -> Result<Self::Inserter<'b>, IncompatibleError>

Enables insertion in self for a new socket with the provided sharing state.

If the new state is incompatible with the existing socket(s), implementations of this function should return Err(IncompatibleError). If Ok(x) is returned, calling x.insert(y) will insert y into self.

Source

fn could_insert( &self, new_sharing_state: &Self::SharingState, ) -> Result<(), IncompatibleError>

Returns Ok if an entry with the given sharing state could be added to self.

If this returns Ok, try_get_dest should succeed.

Source

fn remove_by_id(&mut self, id: Self::Id) -> RemoveResult

Removes the given socket from the existing state.

Implementations should assume that id is contained in self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§