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
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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