pub struct Context { /* private fields */ }Expand description
Shared state handed to every request, cheap to clone.
Implementations§
Source§impl Context
impl Context
pub fn builder() -> ContextBuilder
pub fn config(&self) -> &Config
Sourcepub fn state<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn state<T: Send + Sync + 'static>(&self) -> Option<&T>
Fetch a registered service by type.
Sourcepub fn expect_state<T: Send + Sync + 'static>(&self) -> &T
pub fn expect_state<T: Send + Sync + 'static>(&self) -> &T
Fetch a registered service, panicking with an actionable message if the application forgot to register it. Intended for framework packages that cannot proceed without their own state.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin for Context
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