Struct netstack3_base::socketmap::SocketMap

source ·
pub struct SocketMap<A: Hash + Eq, V: Tagged<A>> { /* private fields */ }
Expand description

A map that stores values and summarizes tag counts.

This provides a similar insertion/removal API to HashMap for individual key/value pairs. Unlike a regular HashMap, the key type A is required to implement IterShadows, and V to implement Tagged.

Since A implements IterShadows, a given value a : A has zero or more shadow values. Since the shadow relationship is transitive, we call any value v that is reachable by following shadows of a one of a’s “ancestors”, and we say a is a “descendant” of v.

In addition to keys and values, this map stores the number of values present in the map for all descendants of each key. These counts are separated into buckets for different tags of type V::Tag.

Implementations§

source§

impl<A, V> SocketMap<A, V>
where A: IterShadows + Hash + Eq, V: Tagged<A>,

source

pub fn len(&self) -> usize

Returns the number of entries in this SocketMap.

source

pub fn get(&self, key: &A) -> Option<&V>

Gets a reference to the value associated with the given key, if any.

source

pub fn entry(&mut self, key: A) -> Entry<'_, A, V>

Provides an Entry for the given key for in-place manipulation.

This is similar to the API provided by HashMap::entry. Callers can match on the result to perform different actions depending on whether the map has a value for the key or not.

source

pub fn descendant_counts( &self, key: &A, ) -> impl ExactSizeIterator<Item = &(V::Tag, NonZeroUsize)>

Returns counts of tags for values at keys that shadow key.

This is equivalent to iterating over all keys in the map, filtering for those keys for which key is one of their shadows, then calling Tagged::tag on the value for each of those keys, and then computing the number of occurrences for each tag.

source

pub fn iter(&self) -> impl Iterator<Item = (&A, &V)>

Returns an iterator over the keys and values in the map.

Trait Implementations§

source§

impl<A: Debug + Hash + Eq, V: Debug + Tagged<A>> Debug for SocketMap<A, V>
where V::Tag: Debug,

source§

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

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

impl<A: Hash + Eq, V: Tagged<A>> Default for SocketMap<A, V>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<A, V> Freeze for SocketMap<A, V>

§

impl<A, V> RefUnwindSafe for SocketMap<A, V>

§

impl<A, V> Send for SocketMap<A, V>
where A: Send, V: Send, <V as Tagged<A>>::Tag: Send,

§

impl<A, V> Sync for SocketMap<A, V>
where A: Sync, V: Sync, <V as Tagged<A>>::Tag: Sync,

§

impl<A, V> Unpin for SocketMap<A, V>
where A: Unpin, V: Unpin, <V as Tagged<A>>::Tag: Unpin,

§

impl<A, V> UnwindSafe for SocketMap<A, V>

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<O, BC> BuildableCoreContext<BC> for O
where O: Default,

§

type Builder = ()

The builder type that can build this core context.
source§

fn build(_bindings_ctx: &mut BC, _: ()) -> O

Consumes this builder and returns the context.
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<CC, BC, Meta> RecvFrameContext<Meta, BC> for CC
where Meta: ReceivableFrameMeta<CC, BC>,

source§

fn receive_frame<B>(&mut self, bindings_ctx: &mut BC, metadata: Meta, frame: B)
where B: BufferMut + Debug,

Receive a frame. Read more
source§

impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CC
where Meta: SendableFrameMeta<CC, BC>,

source§

fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S, ) -> Result<(), ErrorAndSerializer<SendFrameErrorReason, S>>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
source§

impl<Id, CC, BC> TimerHandler<BC, Id> for CC
where BC: TimerBindingsTypes, Id: HandleableTimer<CC, BC>,

source§

fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )

Handle a timer firing. Read more
source§

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

§

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>,

§

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.
§

impl<L, T> UnlockedAccess<L> for T
where L: UnlockedAccessMarkerFor<T>,

§

type Data = <L as UnlockedAccessMarkerFor<T>>::Data

The type of state being accessed.
§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where T: 'l

A guard providing read access to the data.
§

fn access(&self) -> <T as UnlockedAccess<L>>::Guard<'_>

How to access the state.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,