Struct http_types::Extensions [−][src]
pub struct Extensions { /* fields omitted */ }
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
[src]
impl Extensions
[src]pub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T>
[src]
Insert a value into this Extensions
.
If a value of this type already exists, it will be returned.
pub fn contains<T: 'static>(&self) -> bool
[src]
Check if container contains value for type
pub fn get<T: 'static>(&self) -> Option<&T>
[src]
Get a reference to a value previously inserted on this Extensions
.
pub fn get_mut<T: 'static>(&mut self) -> Option<&mut T>
[src]
Get a mutable reference to a value previously inserted on this Extensions
.
pub fn remove<T: 'static>(&mut self) -> Option<T>
[src]
Remove a value from this Extensions
.
If a value of this type exists, it will be returned.
pub fn clear(&mut self)
[src]
Clear the Extensions
of all inserted values.
Trait Implementations
impl Default for Extensions
[src]
impl Default for Extensions
[src]fn default() -> Extensions
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Extensions
impl !RefUnwindSafe for Extensions
impl Send for Extensions
impl Send for Extensions
impl Sync for Extensions
impl Sync for Extensions
impl Unpin for Extensions
impl Unpin for Extensions
impl !UnwindSafe for Extensions
impl !UnwindSafe for Extensions