pub struct Extensions { /* private fields */ }
Expand description
A type to store extra data inside Request
and Response
.
Store and retrieve values by
TypeId
. This allows
storing arbitrary data that implements Sync + Send + 'static
. This is
useful when for example implementing middleware that needs to send values.
Implementations§
Source§impl Extensions
impl Extensions
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 Extensions
.
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 Extensions
.
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 Extensions
.
Trait Implementations§
Source§impl Debug for Extensions
impl Debug for Extensions
Source§impl Default for Extensions
impl Default for Extensions
Source§fn default() -> Extensions
fn default() -> Extensions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Extensions
impl !RefUnwindSafe for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl !UnwindSafe 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