Function serde_dynamo::from_items
source · [−]pub fn from_items<'a, Tin, Tout>(
items: Vec<HashMap<String, Tin>>
) -> Result<Vec<Tout>> where
Tin: AttributeValue,
Tout: Deserialize<'a>,
Expand description
Interpret a Vec<Item>
as Vec<T>
.
TODO
#[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
if let Some(items) = result.items {
let users: Vec<User> = from_items(items)?;
println!("Got {} users", users.len());
}