[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 [rusotodynamodb]'s [getitem], [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.

```rust

[derive(Serialize, Deserialize)]

pub struct User { id: String, name: String, age: u8, };

// Get documents from DynamoDB let input = ScanInput { tablename: "users".tostring(), ..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); } ```

Creating items by serializing data structures

Writing an entire data structure to DynamoDB typically involves using to_item to serialize it.

```rust

[derive(Serialize, Deserialize)]

pub struct User { id: String, name: String, age: u8, };

// Create a user let user = User { id: "fSsgVtal8TpP".tostring(), name: "Arthur Dent".tostring(), age: 42, };

// Turn it into an item that rusoto understands let item = to_item(user)?;

// And write it! let input = PutItemInput { tablename: "users".tostring(), item: item, ..PutItemInput::default() }; client.put_item(input).await?; ```

How serdedynamo compares to serdedynamodb

[serdedynamodb] is an effective library for serializing and deserializing data from [rusotodynamodb].

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 serdedynamodb because making the changes to support these features would cause serdedynamodb to be backward-incompatible. Specifically, for certain cases, serdedynamo and serdedynamodb make different choices on how to serialize the exact same serializable structure.