Struct ajars_surf::surf::http::Extensions
[−]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
impl Extensions
impl Extensions
pub fn insert<T>(&mut self, val: T) -> Option<T> where
T: 'static + Send + Sync,
pub fn insert<T>(&mut self, val: T) -> Option<T> where
T: 'static + Send + Sync,
Insert a value into this Extensions
.
If a value of this type already exists, it will be returned.
pub fn get<T>(&self) -> Option<&T> where
T: 'static,
pub fn get<T>(&self) -> Option<&T> where
T: 'static,
Get a reference to a value previously inserted on this Extensions
.
pub fn get_mut<T>(&mut self) -> Option<&mut T> where
T: 'static,
pub fn get_mut<T>(&mut self) -> Option<&mut T> where
T: 'static,
Get a mutable reference to a value previously inserted on this Extensions
.
pub fn remove<T>(&mut self) -> Option<T> where
T: 'static,
pub fn remove<T>(&mut self) -> Option<T> where
T: 'static,
Remove a value from this Extensions
.
If a value of this type exists, it will be returned.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear the Extensions
of all inserted values.
Trait Implementations
impl Debug for Extensions
impl Debug for Extensions
impl Default for Extensions
impl Default for Extensions
fn default() -> Extensions
fn default() -> Extensions
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl !UnwindSafe for Extensions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more