[][src]Function serde_dynamo::from_item

pub fn from_item<'a, T>(item: Item) -> Result<T> where
    T: Deserialize<'a>, 

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 input = ScanInput {
    table_name: "users".to_string(),
    ..ScanInput::default()
};
let result = client.scan(input).await?;

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