Trait netstack3_base::socket::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.

Object Safety§

This trait is not object safe.

Implementors§