Playing around with Rust SDK and cargo lambda, to create a fn that reads new items appended to a specific table in DynamoDB, which is set as the trigger. I've written a fn as such. What are better approaches to this? I guess the more broader question would be - is there a quicker way to access enum variants that are passed as event
to the handler fn?
fn matchAttribute<T>(attribute: &AttributeValue) -> Option<T>
where
bool: Into<T>,
f64: Into<T>,
String: Into<T>,
T: for<'a> std::convert::From<&'a std::string::String>
{
match attribute {
AttributeValue::Boolean(b) => Some((*b).into()),
AttributeValue::Number(f) => Some((*f).into()),
AttributeValue::String(s) => Some((s).into()),
_ => None,
}
}