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

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.

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

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.

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

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

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.

Gets the given key’s corresponding entry in the map for in-place manipulation.

Returns a reference to the value corresponding to the key.

Returns the key-value pair corresponding to the supplied key.

Returns a mutable reference to the value corresponding to the key.

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.

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.

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.

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a String, &'a SessionData).

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

Returns true if the map contains no elements.

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

Returns the number of elements in the map.

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.

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.

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.

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.

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.

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.

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

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

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.