pub struct Extensions { /* private fields */ }Expand description
Type-erased extensions map for passing data to handlers.
Extensions allow router-level state and middleware-injected data to flow
to tool handlers via the Extension<T> extractor.
Implementations§
Source§impl Extensions
impl Extensions
Sourcepub fn insert<T: Send + Sync + 'static>(&mut self, val: T)
pub fn insert<T: Send + Sync + 'static>(&mut self, val: T)
Insert a value into the extensions map.
If a value of the same type already exists, it is replaced.
Sourcepub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn get<T: Send + Sync + 'static>(&self) -> Option<&T>
Get a reference to a value in the extensions map.
Returns None if no value of the given type has been inserted.
Sourcepub fn contains<T: Send + Sync + 'static>(&self) -> bool
pub fn contains<T: Send + Sync + 'static>(&self) -> bool
Check if the extensions map contains a value of the given type.
Sourcepub fn merge(&mut self, other: &Extensions)
pub fn merge(&mut self, other: &Extensions)
Merge another extensions map into this one.
Values from other will overwrite existing values of the same type.
Trait Implementations§
Source§impl Clone for Extensions
impl Clone for Extensions
Source§fn clone(&self) -> Extensions
fn clone(&self) -> Extensions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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