pub struct SessionData { /* private fields */ }
Expand description
Associated data about a principal. This is a map of ASCII case-insensitive strings to SessionValue values.
This wraps the standard Rust HashMap type, providing the case-insensitive key lookup and setting values to the SessionValue type.
Implementations§
Source§impl SessionData
impl SessionData
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty HashMap.
The underlying hash map is initially created with a capacity of 0, so it will not allocate until it is first inserted into.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new session data object with a pre-allocated capacity.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
This number is a lower bound; the SessionData might be able to hold more, but is guaranteed to be able to hold at least this many.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.
Sourcepub fn contains_key<Q: AsRef<str> + ?Sized>(&self, k: &Q) -> bool
pub fn contains_key<Q: AsRef<str> + ?Sized>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
Sourcepub fn drain(&mut self) -> Drain<'_, String, SessionValue>
pub fn drain(&mut self) -> Drain<'_, String, SessionValue>
Clears the map, returning all key-value pairs as an iterator. Keeps the allocated memory for reuse.
If the returned iterator is dropped before being fully consumed, it drops the remaining key-value pairs. The returned iterator keeps a mutable borrow on the map to optimize its implementation.
Sourcepub fn entry<Q: AsRef<str> + ?Sized>(
&mut self,
key: &Q,
) -> Entry<'_, String, SessionValue>
pub fn entry<Q: AsRef<str> + ?Sized>( &mut self, key: &Q, ) -> Entry<'_, String, SessionValue>
Gets the given key’s corresponding entry in the map for in-place manipulation.
Sourcepub fn get<Q: AsRef<str> + ?Sized>(&self, key: &Q) -> Option<&SessionValue>
pub fn get<Q: AsRef<str> + ?Sized>(&self, key: &Q) -> Option<&SessionValue>
Returns a reference to the value corresponding to the key.
Sourcepub fn get_key_value<Q: AsRef<str> + ?Sized>(
&self,
key: &Q,
) -> Option<(&str, &SessionValue)>
pub fn get_key_value<Q: AsRef<str> + ?Sized>( &self, key: &Q, ) -> Option<(&str, &SessionValue)>
Returns the key-value pair corresponding to the supplied key.
Sourcepub fn get_mut<Q: AsRef<str> + ?Sized>(
&mut self,
key: &Q,
) -> Option<&mut SessionValue>
pub fn get_mut<Q: AsRef<str> + ?Sized>( &mut self, key: &Q, ) -> Option<&mut SessionValue>
Returns a mutable reference to the value corresponding to the key.
Sourcepub fn insert<Q: AsRef<str> + ?Sized>(
&mut self,
key: &Q,
value: SessionValue,
) -> Option<SessionValue>
pub fn insert<Q: AsRef<str> + ?Sized>( &mut self, key: &Q, value: SessionValue, ) -> Option<SessionValue>
Inserts a key-value pair into the map.
If the map did not have this key present, None is returned. If the map did have this key present, the value is updated, and the old value is returned.
Sourcepub fn into_keys(self) -> IntoKeys<String, SessionValue>
pub fn into_keys(self) -> IntoKeys<String, SessionValue>
Creates a consuming iterator visiting all the keys in arbitrary order. The map cannot be used after calling
this. The iterator element type is String
.
Sourcepub fn into_values(self) -> IntoValues<String, SessionValue>
pub fn into_values(self) -> IntoValues<String, SessionValue>
Creates a consuming iterator visiting all the values in arbitrary order. The map cannot be used after calling
this. The iterator element type is SessionValue
.
Sourcepub fn iter(&self) -> Iter<'_, String, SessionValue>
pub fn iter(&self) -> Iter<'_, String, SessionValue>
An iterator visiting all key-value pairs in arbitrary order. The iterator element type is
(&'a String, &'a SessionData)
.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, String, SessionValue>
pub fn iter_mut(&mut self) -> IterMut<'_, String, SessionValue>
An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values. The
iterator element type is (&'a String, &'a mut SessionValue)
.
Sourcepub fn keys(&self) -> Keys<'_, String, SessionValue>
pub fn keys(&self) -> Keys<'_, String, SessionValue>
An iterator visiting all keys in arbitrary order. The iterator element type is &'a String
.
Sourcepub fn remove<Q: AsRef<str> + ?Sized>(
&mut self,
key: &Q,
) -> Option<SessionValue>
pub fn remove<Q: AsRef<str> + ?Sized>( &mut self, key: &Q, ) -> Option<SessionValue>
Removes a key from the map, returning the value at the key if the key was previously in the map.
Sourcepub fn remove_entry<Q: AsRef<str> + ?Sized>(
&mut self,
key: &Q,
) -> Option<(String, SessionValue)>
pub fn remove_entry<Q: AsRef<str> + ?Sized>( &mut self, key: &Q, ) -> Option<(String, SessionValue)>
Removes a key from the map, returning the stored key and value if the key was previously in the map.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted in the SessionData
. The collection
may reserve more space to speculatively avoid frequent reallocations. After calling reserve
, capacity will be
greater than or equal to self.len() + additional
. Does nothing if capacity is already sufficient.
§Panics
Panics if the new allocation size overflows usize
.
Sourcepub fn retain<F: FnMut(&str, &mut SessionValue) -> bool>(&mut self, f: F)
pub fn retain<F: FnMut(&str, &mut SessionValue) -> bool>(&mut self, f: F)
Retains only the elements specified by the predicate.
In other words, remove all pairs (k, v)
for which f(&k, &mut v)
returns false
. The elements are visited
in unsorted (and unspecified) order.
Sourcepub fn shrink_to(&mut self, min_capacity: usize)
pub fn shrink_to(&mut self, min_capacity: usize)
Shrinks the capacity of the map with a lower limit. It will drop down no lower than the supplied limit while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.
If the current capacity is less than the lower limit, this is a no-op.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.
Sourcepub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
Tries to reserve capacity for at least additional
more elements to be inserted in the SessionData
. The
collection may reserve more space to speculatively avoid frequent reallocations. After calling try_reserve
,
capacity will be greater than or equal to self.len() + additional
if it returns Ok(())
. Does nothing if
capacity is already sufficient.
§Errors
If the capacity overflows, or the allocator reports a failure, then an error is returned.
Sourcepub fn values(&self) -> Values<'_, String, SessionValue>
pub fn values(&self) -> Values<'_, String, SessionValue>
An iterator visiting all values in arbitrary order. The iterator element type is &'a SessionValue
.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, String, SessionValue>
pub fn values_mut(&mut self) -> ValuesMut<'_, String, SessionValue>
An iterator visiting all values mutably in arbitrary order. The iterator element type is &'a mut SessionValue
.
Trait Implementations§
Source§impl Clone for SessionData
impl Clone for SessionData
Source§fn clone(&self) -> SessionData
fn clone(&self) -> SessionData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SessionData
impl Debug for SessionData
Source§impl Default for SessionData
impl Default for SessionData
Source§impl<'a, K: AsRef<str> + ?Sized> Extend<(&'a K, &'a SessionValue)> for SessionData
impl<'a, K: AsRef<str> + ?Sized> Extend<(&'a K, &'a SessionValue)> for SessionData
Source§fn extend<T: IntoIterator<Item = (&'a K, &'a SessionValue)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (&'a K, &'a SessionValue)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)