netstack3_base::socketmap

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

Source§

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

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

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