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>
impl<V> InlineTokenMap<V>
pub const fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn contains_key(&self, token: &Token) -> bool
pub fn get(&self, token: &Token) -> Option<&V>
pub fn get_mut(&mut self, token: &Token) -> Option<&mut V>
Sourcepub fn get_or_insert_with(
&mut self,
token: Token,
default: impl FnOnce() -> V,
) -> &mut V
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.
Sourcepub fn retain(&mut self, keep: impl FnMut(&Token, &mut V) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&Token, &mut V) -> bool)
Keep only the entries keep answers true for.