pub struct RequestExtensions(/* private fields */);Expand description
Type-safe, request-scoped extension container.
Keyed by TypeId, so only one value per concrete type is
stored. Use private newtypes to avoid collisions between
independent filters.
Implementations§
Source§impl RequestExtensions
impl RequestExtensions
Sourcepub fn insert<T: Send + Sync + 'static>(&mut self, val: T)
pub fn insert<T: Send + Sync + 'static>(&mut self, val: T)
Insert a typed value, replacing any previous value of the same type.
Sourcepub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
Get a shared reference to a stored value by type.
Sourcepub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
pub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
Get an exclusive reference to a stored value by type.
Sourcepub fn get_or_insert_with<T: Send + Sync + 'static>(
&mut self,
f: impl FnOnce() -> T,
) -> &mut T
pub fn get_or_insert_with<T: Send + Sync + 'static>( &mut self, f: impl FnOnce() -> T, ) -> &mut T
Get an exclusive reference to a stored value, inserting a
default computed by f if absent.
§Panics
Cannot panic in practice: the value was just inserted with
the correct type. The expect guards against impossible
TypeId collisions in the standard library.
Trait Implementations§
Source§impl Default for RequestExtensions
impl Default for RequestExtensions
Source§fn default() -> RequestExtensions
fn default() -> RequestExtensions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for RequestExtensions
impl !UnwindSafe for RequestExtensions
impl Freeze for RequestExtensions
impl Send for RequestExtensions
impl Sync for RequestExtensions
impl Unpin for RequestExtensions
impl UnsafeUnpin for RequestExtensions
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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