pub struct StringAttribute;Expand description
Marker type for DynamoDB String (S) attributes.
Use this as the Type in an attribute_definitions!
block to declare that an attribute stores a string value. Rust types
that implement IntoTypedAttributeValue<StringAttribute>
include String, &str, &String, and Cow<'_, str>.
The type system enforces this constraint at compile time: passing a
value of the wrong type (e.g. a u32 or Vec<u8>) to a
StringAttribute attribute will not compile.
§Examples
use dynamodb_facade::{attribute_definitions, has_attributes, StringAttribute};
attribute_definitions! {
Label { "label": StringAttribute }
}
struct MyItem;
// ✓ &'static str implements IntoTypedAttributeValue<StringAttribute>
has_attributes! {
MyItem {
Label { const VALUE: &'static str = "hello"; }
}
}
struct OtherItem;
// ✓ String also works
has_attributes! {
OtherItem {
Label { fn attribute_value(id) -> String { "world".to_owned() } }
}
}
// These would NOT compile — wrong attribute type:
// has_attributes! { MyItem { Label { const VALUE: u32 = 42; } } }
// has_attributes! { MyItem { Label { fn attribute_value(id) -> Vec<u8> { vec![] } } } }Trait Implementations§
Source§impl Clone for StringAttribute
impl Clone for StringAttribute
Source§fn clone(&self) -> StringAttribute
fn clone(&self) -> StringAttribute
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StringAttribute
impl Debug for StringAttribute
impl AttributeType for StringAttribute
impl Copy for StringAttribute
impl<T: IntoStringAttributeValue + IntoAttributeValue> IntoTypedAttributeValue<StringAttribute> for T
Auto Trait Implementations§
impl Freeze for StringAttribute
impl RefUnwindSafe for StringAttribute
impl Send for StringAttribute
impl Sync for StringAttribute
impl Unpin for StringAttribute
impl UnsafeUnpin for StringAttribute
impl UnwindSafe for StringAttribute
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.