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

Create an empty PropertyBag.

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"))
);

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));

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");

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());

Clear the PropertyBag of all inserted extensions.

Examples
let mut props = PropertyBag::new();
props.insert(5i32);
props.clear();

assert!(props.get::<i32>().is_none());

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more