pub struct Extensions { /* private fields */ }
Implementations§
Source§impl Extensions
impl Extensions
pub fn new() -> Self
Sourcepub fn insert<T: Send + Sync + 'static>(&self, val: T) -> InsertEffect
pub fn insert<T: Send + Sync + 'static>(&self, val: T) -> InsertEffect
Inserts a new value into the extension map. It will replace any existing value with the same TypeId.
Note that any outstanding get
/get_arc
on the type will not be altered.
Sourcepub fn get<'a, T: Send + Sync + 'static>(&'a self) -> Option<&'a T>
pub fn get<'a, T: Send + Sync + 'static>(&'a self) -> Option<&'a T>
Gets a reference to an extension value. This will invalidate that value from ever being manually removed.
Sourcepub fn get_arc<T: Send + Sync + 'static>(&self) -> Option<Arc<T>>
pub fn get_arc<T: Send + Sync + 'static>(&self) -> Option<Arc<T>>
Gets a reference to an extension value.
Since it returns an Arc
and tracks it’s deallocation, it does not prevent a value from being manually removed.
However, while the Arc
is alive, it cannot be removed.
Take care that the Arc
doesn’t outlive the Request/Response, otherwise there will be a panic.
Sourcepub fn remove<T: Send + Sync + 'static>(&self) -> Option<Removed<T>>
pub fn remove<T: Send + Sync + 'static>(&self) -> Option<Removed<T>>
Removes a non-invalidated entry from the Extensions map
pub fn extend(&self, other: &Extensions)
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
Source§impl From<Extensions> for Extensions
impl From<Extensions> for Extensions
Source§fn from(value: Extensions) -> Self
fn from(value: Extensions) -> Self
Converts to this type from the input type.
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