DynamoDB is an AWS database that stores key/value and document data.
The most common way to access DynamoDB data from Rust is to use rusoto_dynamodb's get_item, put_item, and related methods.
serde_dynamo provides a way to serialize and deserialize between data stored in these items and strongly-typed Rust data structures.
You may be looking for
Examples
See the docs for more examples.
Parsing items as strongly-typed data structures.
Items received from a rusoto_dynamodb call can be run through from_item
.
;
// Get documents from DynamoDB
let input = ScanInput ;
let result = client.scan.await?;
// And deserialize them as strongly-typed data structures
for item in result.items.unwrap
Creating items by serializing data structures
Writing an entire data structure to DynamoDB typically involves using to_item
to serialize
it.
;
// Create a user
let user = User ;
// Turn it into an item that rusoto understands
let item = to_item?;
// And write it!
let input = PutItemInput ;
client.put_item.await?;
How serde_dynamo compares to serde_dynamodb
serde_dynamodb is an effective library for serializing and deserializing data from rusoto_dynamodb.
However, serde_dynamodb is unable to handle some of the more advanced features of serde – especially features like flattening, adjacently tagged enums, and untagged enums – that we would like to use.
We opted to create a new library instead of making changes to serde_dynamodb because making the changes to support these features would cause serde_dynamodb to be backward-incompatible. Specifically, for certain cases, serde_dynamo and serde_dynamodb make different choices on how to serialize the exact same serializable structure.