Struct aws_smithy_http::property_bag::PropertyBag
source · pub struct PropertyBag { /* private fields */ }
Expand description
A type-map of configuration data.
PropertyBag
can be used by Request
and Response
to store
data used to configure the SDK request pipeline.
Implementations§
source§impl PropertyBag
impl PropertyBag
sourcepub fn new() -> PropertyBag
pub fn new() -> PropertyBag
Create an empty PropertyBag
.
sourcepub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T>
pub fn insert<T: Send + Sync + 'static>(&mut self, val: T) -> Option<T>
Insert a type into this PropertyBag
.
If a value of this type already existed, it will be returned.
Examples
let mut props = PropertyBag::new();
#[derive(Debug, Eq, PartialEq)]
struct Endpoint(&'static str);
assert!(props.insert(Endpoint("dynamo.amazon.com")).is_none());
assert_eq!(
props.insert(Endpoint("kinesis.amazon.com")),
Some(Endpoint("dynamo.amazon.com"))
);
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 PropertyBag
.
Examples
let mut props = PropertyBag::new();
assert!(props.get::<i32>().is_none());
props.insert(5i32);
assert_eq!(props.get::<i32>(), Some(&5i32));
sourcepub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
pub fn get_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
Get a mutable reference to a type previously inserted on this PropertyBag
.
Examples
let mut props = PropertyBag::new();
props.insert(String::from("Hello"));
props.get_mut::<String>().unwrap().push_str(" World");
assert_eq!(props.get::<String>().unwrap(), "Hello World");
sourcepub fn remove<T: Send + Sync + 'static>(&mut self) -> Option<T>
pub fn remove<T: Send + Sync + 'static>(&mut self) -> Option<T>
Remove a type from this PropertyBag
.
If a value of this type existed, it will be returned.
Examples
let mut props = PropertyBag::new();
props.insert(5i32);
assert_eq!(props.remove::<i32>(), Some(5i32));
assert!(props.get::<i32>().is_none());
Trait Implementations§
source§impl Debug for PropertyBag
impl Debug for PropertyBag
source§impl Default for PropertyBag
impl Default for PropertyBag
source§fn default() -> PropertyBag
fn default() -> PropertyBag
Returns the “default value” for a type. Read more
source§fn from(bag: PropertyBag) -> Self
fn from(bag: PropertyBag) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for PropertyBag
impl Send for PropertyBag
impl Sync for PropertyBag
impl Unpin for PropertyBag
impl !UnwindSafe for PropertyBag
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