in src/entrypoints/lambda/dynamodb/model.rs [169:189]
fn try_from(value: &HashMap<String, AttributeValue>) -> Result<Self, Self::Error> {
Ok(Product {
id: value
.get("id")
.ok_or(Error::InternalError("Missing id"))?
.as_s()
.ok_or(Error::InternalError("id is not a string"))?
.to_string(),
name: value
.get("name")
.ok_or(Error::InternalError("Missing name"))?
.as_s()
.ok_or(Error::InternalError("name is not a string"))?
.to_string(),
price: value
.get("price")
.ok_or(Error::InternalError("Missing price"))?
.as_n()
.ok_or(Error::InternalError("price is not a number"))?,
})
}