Struct SessionData

Source
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

Source

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.

Source

pub fn with_capacity(capacity: usize) -> Self

Create a new session data object with a pre-allocated capacity.

Source

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.

Source

pub fn clear(&mut self)

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

Source

pub fn contains_key<Q: AsRef<str> + ?Sized>(&self, k: &Q) -> bool

Returns true if the map contains a value for the specified key.

Source

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.

Source

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.

Source

pub fn get<Q: AsRef<str> + ?Sized>(&self, key: &Q) -> Option<&SessionValue>

Returns a reference to the value corresponding to the key.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Source

pub fn keys(&self) -> Keys<'_, String, SessionValue>

An iterator visiting all keys in arbitrary order. The iterator element type is &'a String.

Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn values(&self) -> Values<'_, String, SessionValue>

An iterator visiting all values in arbitrary order. The iterator element type is &'a SessionValue.

Source

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

Source§

fn clone(&self) -> SessionData

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionData

Source§

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

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

impl Default for SessionData

Source§

fn default() -> Self

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

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)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K: AsRef<str>, const N: usize> From<[(K, SessionValue); N]> for SessionData

Source§

fn from(variables: [(K, SessionValue); N]) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, SessionValue>> for SessionData

Source§

fn from(variables: HashMap<String, SessionValue>) -> Self

Converts to this type from the input type.
Source§

impl<K: AsRef<str>> FromIterator<(K, SessionValue)> for SessionData

Source§

fn from_iter<T: IntoIterator<Item = (K, SessionValue)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<Q: AsRef<str> + ?Sized> Index<&Q> for SessionData

Source§

type Output = SessionValue

The returned type after indexing.
Source§

fn index(&self, key: &Q) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a SessionData

Source§

type Item = (&'a String, &'a SessionValue)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, String, SessionValue>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut SessionData

Source§

type Item = (&'a String, &'a mut SessionValue)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, String, SessionValue>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for SessionData

Source§

type Item = (String, SessionValue)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<String, SessionValue>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq<HashMap<String, SessionValue>> for SessionData

Source§

fn eq(&self, other: &HashMap<String, SessionValue>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for SessionData

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SessionData

Source§

impl UnwindSafe for SessionData

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.