Skip to main content

InlineTokenMap

Struct InlineTokenMap 

Source
pub struct InlineTokenMap<V> { /* private fields */ }
Expand description

A map keyed by Token that holds its lowest-token entry inline.

A session almost always has exactly one backend connection, so the two per-backend indexes a mux session keeps — Context::backend_streams and the backend half of MuxTimeouts — almost always hold one entry. A HashMap allocated its table on that first insert, once per session and so once per request on a one-request connection (#1613). Here the first entry costs nothing and only a second backend reaches the overflow map.

The shape is BackendConnections’s: first is None only when rest is empty, and its token is below every token in rest, so iteration runs in ascending Token order.

Implementations§

Source§

impl<V> InlineTokenMap<V>

Source

pub const fn new() -> Self

Source

pub fn is_empty(&self) -> bool

Source

pub fn contains_key(&self, token: &Token) -> bool

Source

pub fn get(&self, token: &Token) -> Option<&V>

Source

pub fn get_mut(&mut self, token: &Token) -> Option<&mut V>

Source

pub fn get_or_insert_with( &mut self, token: Token, default: impl FnOnce() -> V, ) -> &mut V

The value under token, inserting default() first when there is none.

Source

pub fn remove(&mut self, token: &Token) -> Option<V>

Remove and return the value under token.

Source

pub fn retain(&mut self, keep: impl FnMut(&Token, &mut V) -> bool)

Keep only the entries keep answers true for.

Source

pub fn clear(&mut self)

Source

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

The entries in ascending Token order.

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Trait Implementations§

Source§

impl<V: Debug> Debug for InlineTokenMap<V>

Source§

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

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

impl<V> Default for InlineTokenMap<V>

Source§

fn default() -> Self

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

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.