Struct aws_smithy_types::config_bag::CloneableLayer
source · pub struct CloneableLayer(/* private fields */);
Expand description
CloneableLayer
allows itself to be cloned. This is useful when a type that implements
Clone
wishes to store a config layer.
It ensures that all the items in CloneableLayer
are Clone
upon entry, e.g. when they are
first stored, the mutable methods require that they have a Clone
bound on them.
While FrozenLayer
is also cloneable, which is a shallow clone via Arc
, CloneableLayer
performs a deep clone that newly allocates all the items stored in it.
Cloneable enforces that non clone items cannot be added
use aws_smithy_types::config_bag::Storable;
use aws_smithy_types::config_bag::StoreReplace;
use aws_smithy_types::config_bag::CloneableLayer;
#[derive(Debug)]
struct MyNotCloneStruct;
impl Storable for MyNotCloneStruct {
type Storer = StoreReplace<MyNotCloneStruct>;
}
let mut layer = CloneableLayer::new("layer");
layer.store_put(MyNotCloneStruct);
See the module docs for more documentation.
Implementations§
source§impl CloneableLayer
impl CloneableLayer
sourcepub fn new(name: impl Into<Cow<'static, str>>) -> Self
pub fn new(name: impl Into<Cow<'static, str>>) -> Self
Creates a new CloneableLayer
with a given name
sourcepub fn freeze(self) -> FrozenLayer
pub fn freeze(self) -> FrozenLayer
Converts this layer into a frozen layer that can no longer be mutated.
sourcepub fn unset<T: Send + Sync + Clone + Debug + 'static>(&mut self) -> &mut Self
pub fn unset<T: Send + Sync + Clone + Debug + 'static>(&mut self) -> &mut Self
Removes T
from this bag
sourcepub fn store_put<T>(&mut self, item: T) -> &mut Self
pub fn store_put<T>(&mut self, item: T) -> &mut Self
Stores item
of type T
into the config bag, overriding a previous value of the same type
sourcepub fn store_or_unset<T>(&mut self, item: Option<T>) -> &mut Self
pub fn store_or_unset<T>(&mut self, item: Option<T>) -> &mut Self
Stores item
of type T
into the config bag, overriding a previous value of the same type,
or unsets it by passing a None
sourcepub fn store_append<T>(&mut self, item: T) -> &mut Self
pub fn store_append<T>(&mut self, item: T) -> &mut Self
Stores item
of type T
into the config bag, appending it to the existing list of the same
type