pub struct NumberAttribute;Expand description
Marker type for DynamoDB Number (N) attributes.
Use this as the Type in an attribute_definitions!
block to declare that an attribute stores a numeric value. Rust types
that implement IntoTypedAttributeValue<NumberAttribute>
include all integer and floating-point primitives, as well as
AsNumber<T> (for pre-formatted number strings).
The type system enforces this constraint at compile time: passing a
value of the wrong type (e.g. a &str or Vec<u8>) to a
NumberAttribute attribute will not compile.
§Examples
use dynamodb_facade::{attribute_definitions, has_attributes, NumberAttribute};
attribute_definitions! {
Score { "score": NumberAttribute }
}
struct MyItem;
// ✓ u32 implements IntoTypedAttributeValue<NumberAttribute>
has_attributes! {
MyItem {
Score { fn attribute_value(id) -> u32 { 100 } }
}
}
struct OtherItem;
// ✓ i64 also works
has_attributes! {
OtherItem {
Score { fn attribute_value(id) -> i64 { -5 } }
}
}
// These would NOT compile — wrong attribute type:
// has_attributes! { MyItem { Score { const VALUE: &'static str = "hi"; } } }
// has_attributes! { MyItem { Score { fn attribute_value(id) -> Vec<u8> { vec![] } } } }Trait Implementations§
Source§impl Clone for NumberAttribute
impl Clone for NumberAttribute
Source§fn clone(&self) -> NumberAttribute
fn clone(&self) -> NumberAttribute
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 NumberAttribute
impl Debug for NumberAttribute
impl AttributeType for NumberAttribute
impl Copy for NumberAttribute
Auto Trait Implementations§
impl Freeze for NumberAttribute
impl RefUnwindSafe for NumberAttribute
impl Send for NumberAttribute
impl Sync for NumberAttribute
impl Unpin for NumberAttribute
impl UnsafeUnpin for NumberAttribute
impl UnwindSafe for NumberAttribute
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.