Skip to main content

IntoAttributeValue

Trait IntoAttributeValue 

Source
pub trait IntoAttributeValue {
    // Required method
    fn into_attribute_value(self) -> AttributeValue;
}
Expand description

Converts a Rust value into a DynamoDB AttributeValue.

This trait is the bridge between Rust types and the DynamoDB wire format. It is implemented for all common scalar types, collections, and the AsSet and AsNumber<T> newtypes:

Rust typeDynamoDB type
String, &str, &StringS
boolBOOL
Integer and float primitivesN
Vec<u8>, [&[u8]]B
Vec<T>, [&[T]] (where T is a scalar)L
HashSet<String>, BTreeSet<String>SS
HashSet<N>, BTreeSet<N> (numeric)NS
HashSet<Vec<u8>>, BTreeSet<Vec<u8>>BS
AsSet<String>SS
AsSet<N> (numeric)NS
AsSet<Vec<u8>>BS
AsNumber<T>N
AttributeValueidentity

Implement this trait for your own domain types to use them directly in expression builders (e.g. Update::set("field", my_value)).

§Examples

use dynamodb_facade::{AttributeValue, IntoAttributeValue};

// Strings become AttributeValue::S
let av = "alice@example.com".into_attribute_value();
assert_eq!(av, AttributeValue::S("alice@example.com".to_owned()));

// Numbers become AttributeValue::N
let av = 42.into_attribute_value();
assert_eq!(av, AttributeValue::N("42".to_owned()));

// Custom domain type
struct UserId(String);
impl IntoAttributeValue for UserId {
    fn into_attribute_value(self) -> AttributeValue {
        self.0.into_attribute_value()
    }
}

let av = UserId("user-1".to_owned()).into_attribute_value();
assert_eq!(av, AttributeValue::S("user-1".to_owned()));

Required Methods§

Source

fn into_attribute_value(self) -> AttributeValue

Converts self into a DynamoDB AttributeValue.

Implementations on Foreign Types§

Source§

impl IntoAttributeValue for &str

Source§

impl IntoAttributeValue for &String

Source§

impl IntoAttributeValue for &[&str]

Source§

impl IntoAttributeValue for &[&[u8]]

Source§

impl IntoAttributeValue for &[AttributeValue]

Source§

impl IntoAttributeValue for &[bool]

Source§

impl IntoAttributeValue for &[f32]

Source§

impl IntoAttributeValue for &[f64]

Source§

impl IntoAttributeValue for &[i8]

Source§

impl IntoAttributeValue for &[i16]

Source§

impl IntoAttributeValue for &[i32]

Source§

impl IntoAttributeValue for &[i64]

Source§

impl IntoAttributeValue for &[i128]

Source§

impl IntoAttributeValue for &[isize]

Source§

impl IntoAttributeValue for &[u8]

Source§

impl IntoAttributeValue for &[u16]

Source§

impl IntoAttributeValue for &[u32]

Source§

impl IntoAttributeValue for &[u64]

Source§

impl IntoAttributeValue for &[u128]

Source§

impl IntoAttributeValue for &[usize]

Source§

impl IntoAttributeValue for &[String]

Source§

impl IntoAttributeValue for &[Vec<u8>]

Source§

impl IntoAttributeValue for Cow<'_, str>

Source§

impl IntoAttributeValue for bool

Source§

impl IntoAttributeValue for f32

Source§

impl IntoAttributeValue for f64

Source§

impl IntoAttributeValue for i8

Source§

impl IntoAttributeValue for i16

Source§

impl IntoAttributeValue for i32

Source§

impl IntoAttributeValue for i64

Source§

impl IntoAttributeValue for i128

Source§

impl IntoAttributeValue for isize

Source§

impl IntoAttributeValue for u8

Source§

impl IntoAttributeValue for u16

Source§

impl IntoAttributeValue for u32

Source§

impl IntoAttributeValue for u64

Source§

impl IntoAttributeValue for u128

Source§

impl IntoAttributeValue for usize

Source§

impl IntoAttributeValue for BTreeSet<&str>

Source§

impl IntoAttributeValue for BTreeSet<f32>

Source§

impl IntoAttributeValue for BTreeSet<f64>

Source§

impl IntoAttributeValue for BTreeSet<i8>

Source§

impl IntoAttributeValue for BTreeSet<i16>

Source§

impl IntoAttributeValue for BTreeSet<i32>

Source§

impl IntoAttributeValue for BTreeSet<i64>

Source§

impl IntoAttributeValue for BTreeSet<i128>

Source§

impl IntoAttributeValue for BTreeSet<isize>

Source§

impl IntoAttributeValue for BTreeSet<u8>

Source§

impl IntoAttributeValue for BTreeSet<u16>

Source§

impl IntoAttributeValue for BTreeSet<u32>

Source§

impl IntoAttributeValue for BTreeSet<u64>

Source§

impl IntoAttributeValue for BTreeSet<u128>

Source§

impl IntoAttributeValue for BTreeSet<usize>

Source§

impl IntoAttributeValue for BTreeSet<String>

Source§

impl IntoAttributeValue for BTreeSet<Vec<u8>>

Source§

impl IntoAttributeValue for String

Source§

impl IntoAttributeValue for Vec<&str>

Source§

impl IntoAttributeValue for Vec<AttributeValue>

Source§

impl IntoAttributeValue for Vec<bool>

Source§

impl IntoAttributeValue for Vec<f32>

Source§

impl IntoAttributeValue for Vec<f64>

Source§

impl IntoAttributeValue for Vec<i8>

Source§

impl IntoAttributeValue for Vec<i16>

Source§

impl IntoAttributeValue for Vec<i32>

Source§

impl IntoAttributeValue for Vec<i64>

Source§

impl IntoAttributeValue for Vec<i128>

Source§

impl IntoAttributeValue for Vec<isize>

Source§

impl IntoAttributeValue for Vec<u8>

Source§

impl IntoAttributeValue for Vec<u16>

Source§

impl IntoAttributeValue for Vec<u32>

Source§

impl IntoAttributeValue for Vec<u64>

Source§

impl IntoAttributeValue for Vec<u128>

Source§

impl IntoAttributeValue for Vec<usize>

Source§

impl IntoAttributeValue for Vec<String>

Source§

impl IntoAttributeValue for Vec<Vec<u8>>

Source§

impl IntoAttributeValue for HashSet<&str>

Source§

impl IntoAttributeValue for HashSet<f32>

Source§

impl IntoAttributeValue for HashSet<f64>

Source§

impl IntoAttributeValue for HashSet<i8>

Source§

impl IntoAttributeValue for HashSet<i16>

Source§

impl IntoAttributeValue for HashSet<i32>

Source§

impl IntoAttributeValue for HashSet<i64>

Source§

impl IntoAttributeValue for HashSet<i128>

Source§

impl IntoAttributeValue for HashSet<isize>

Source§

impl IntoAttributeValue for HashSet<u8>

Source§

impl IntoAttributeValue for HashSet<u16>

Source§

impl IntoAttributeValue for HashSet<u32>

Source§

impl IntoAttributeValue for HashSet<u64>

Source§

impl IntoAttributeValue for HashSet<u128>

Source§

impl IntoAttributeValue for HashSet<usize>

Source§

impl IntoAttributeValue for HashSet<String>

Source§

impl IntoAttributeValue for HashSet<Vec<u8>>

Implementors§