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
Methods from Deref<Target = Layer>§
Trait Implementations§
source§impl Clone for CloneableLayer
impl Clone for CloneableLayer
source§impl Debug for CloneableLayer
impl Debug for CloneableLayer
source§impl Default for CloneableLayer
impl Default for CloneableLayer
source§fn default() -> CloneableLayer
fn default() -> CloneableLayer
source§impl Deref for CloneableLayer
impl Deref for CloneableLayer
source§impl From<CloneableLayer> for Layer
impl From<CloneableLayer> for Layer
source§fn from(cloneable_layer: CloneableLayer) -> Layer
fn from(cloneable_layer: CloneableLayer) -> Layer
Auto Trait Implementations§
impl Freeze for CloneableLayer
impl !RefUnwindSafe for CloneableLayer
impl Send for CloneableLayer
impl Sync for CloneableLayer
impl Unpin for CloneableLayer
impl !UnwindSafe for CloneableLayer
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
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)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more