Struct trillium_http::StateSet
source · pub struct StateSet(_);Expand description
Store and retrieve values by
TypeId. This
allows storing arbitrary data that implements Sync + Send + 'static.
Implementations§
source§impl StateSet
impl StateSet
sourcepub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T>
pub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T>
Insert a value into this StateSet.
If a value of this type already exists, it will be returned.
sourcepub fn get<T: 'static>(&self) -> Option<&T>
pub fn get<T: 'static>(&self) -> Option<&T>
Get a reference to a value previously inserted on this StateSet.
sourcepub fn get_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn get_mut<T: 'static>(&mut self) -> Option<&mut T>
Get a mutable reference to a value previously inserted on this StateSet.
sourcepub fn take<T: 'static>(&mut self) -> Option<T>
pub fn take<T: 'static>(&mut self) -> Option<T>
Remove a value from this StateSet.
If a value of this type exists, it will be returned.
sourcepub fn get_or_insert<T: Send + Sync + 'static>(&mut self, default: T) -> &mut T
pub fn get_or_insert<T: Send + Sync + 'static>(&mut self, default: T) -> &mut T
Gets a value from this StateSet or populates it with the
provided default.