pub struct StateContainer { /* private fields */ }Expand description
Type-safe application state container.
State is stored by type and can be accessed by handlers through
the State<T> extractor.
Implementations§
Source§impl StateContainer
impl StateContainer
Sourcepub fn insert<T: Send + Sync + 'static>(&mut self, value: T)
pub fn insert<T: Send + Sync + 'static>(&mut self, value: T)
Inserts a value into the state container.
If a value of the same type already exists, it is replaced.
Sourcepub fn insert_any(&mut self, value: Box<dyn Any + Send + Sync>)
pub fn insert_any(&mut self, value: Box<dyn Any + Send + Sync>)
Inserts a boxed Any value into the state container.
This is used by the lifespan system to insert type-erased state. The TypeId is obtained from the actual type inside the box.
Sourcepub fn get<T: Send + Sync + 'static>(&self) -> Option<Arc<T>>
pub fn get<T: Send + Sync + 'static>(&self) -> Option<Arc<T>>
Gets a reference to a value in the state container.
Trait Implementations§
Source§impl Debug for StateContainer
impl Debug for StateContainer
Source§impl Default for StateContainer
impl Default for StateContainer
Source§fn default() -> StateContainer
fn default() -> StateContainer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StateContainer
impl !RefUnwindSafe for StateContainer
impl Send for StateContainer
impl Sync for StateContainer
impl Unpin for StateContainer
impl !UnwindSafe for StateContainer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).