pub struct Configs { /* private fields */ }Expand description
A type map of protocol extensions.
Configs can be used by Request and Response to store
extra data derived from the underlying protocol.
Implementations§
source§impl Configs
impl Configs
sourcepub fn insert<T: Send + Sync + Clone + 'static>(&mut self, val: T) -> Option<T>
pub fn insert<T: Send + Sync + Clone + 'static>(&mut self, val: T) -> Option<T>
Insert a type into this Configs.
If a extension of this type already existed, it will be returned.
§Example
let mut cfg = Configs::new();
assert!(cfg.insert(5i32).is_none());
assert!(cfg.insert(4u8).is_none());
assert_eq!(cfg.insert(9i32), Some(5i32));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 type previously inserted on this Configs.
§Example
let mut cfg = Configs::new();
assert!(cfg.get::<i32>().is_none());
cfg.insert(5i32);
assert_eq!(cfg.get::<i32>(), Some(&5i32));sourcepub fn remove<T: Send + Sync + Clone + 'static>(&mut self) -> Option<T>
pub fn remove<T: Send + Sync + Clone + 'static>(&mut self) -> Option<T>
Remove a type from this Configs.
If a extension of this type existed, it will be returned.
§Example
let mut cfg = Configs::new();
cfg.insert(5i32);
assert_eq!(cfg.remove::<i32>(), Some(5i32));
assert!(cfg.get::<i32>().is_none());sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the Configs of all inserted extensions.
§Example
let mut cfg = Configs::new();
cfg.insert(5i32);
cfg.clear();
assert!(cfg.get::<i32>().is_none());Trait Implementations§
Auto Trait Implementations§
impl Freeze for Configs
impl !RefUnwindSafe for Configs
impl Send for Configs
impl Sync for Configs
impl Unpin for Configs
impl !UnwindSafe for Configs
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)