Function serde_dynamo::from_item

source ·
pub fn from_item<'a, I, T>(item: I) -> Result<T>
where I: Into<Item>, T: Deserialize<'a>,
Expand description

Interpret an Item as an instance of type T.

#[derive(Serialize, Deserialize)]
pub struct User {
    id: String,
    name: String,
    age: u8,

// Get documents from DynamoDB
let result = client.scan().table_name("user").send().await?;

// And deserialize them as strongly-typed data structures
for item in result.items().to_vec() {
    let user: User = from_item(item)?;
    println!("{} is {}",, user.age);