pub struct Extensions(/* private fields */);Expand description
A typed, request-scoped bag.
This is the mechanism middleware uses to hand values to downstream
middleware and to the action — and the substrate the auth, db and
services fields will be built on. It works precisely because the context
is owned and threaded through one chain rather than rebuilt per step.
Implementations§
Source§impl Extensions
impl Extensions
pub fn new() -> Self
Sourcepub fn insert<T: Any + Send + Sync>(&mut self, value: T) -> Option<T>
pub fn insert<T: Any + Send + Sync>(&mut self, value: T) -> Option<T>
Insert a value, returning any previous value of the same type.
pub fn get<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn get_mut<T: Any + Send + Sync>(&mut self) -> Option<&mut T>
pub fn take<T: Any + Send + Sync>(&mut self) -> Option<T>
pub fn contains<T: Any + Send + Sync>(&self) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Debug for Extensions
impl Debug for Extensions
Auto Trait Implementations§
impl !RefUnwindSafe for Extensions
impl !UnwindSafe for Extensions
impl Freeze for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl UnsafeUnpin for Extensions
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