Struct trillium_http::StateSet
source · pub struct StateSet(/* private fields */);
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StateSet
impl Send for StateSet
impl Sync for StateSet
impl Unpin for StateSet
impl !UnwindSafe for StateSet
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more