Skip to content

Commit b9d64e8

Browse files
authored
Updated all crates (awslabs#709)
removed the deprecated mod "Attribute_value" added serde_dynamo "to_attribute_value" updated the code to match the new changes awslabs#708
1 parent 2675fa9 commit b9d64e8

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

examples/http-dynamodb/Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ edition = "2021"
1111
# and it will keep the alphabetic ordering for you.
1212

1313
[dependencies]
14-
simple-error = "0.2.3"
15-
serde_json = "1.0"
16-
serde = { version = "1.0", features = ["derive"] }
14+
simple-error = "0.3.0"
15+
serde_json = "1.0.107"
16+
serde = { version = "1.0.189", features = ["derive"] }
17+
serde_dynamo = {version = "^4.2.7", features = ["aws-sdk-dynamodb+0_33"]}
1718
lambda_http = { path = "../../lambda-http" }
1819
lambda_runtime = { path = "../../lambda-runtime" }
19-
aws-sdk-dynamodb = "0.21.0"
20-
aws-config = "0.51.0"
21-
tokio = { version = "1", features = ["macros"] }
22-
tracing = { version = "0.1", features = ["log"] }
23-
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }
20+
aws-sdk-dynamodb = "0.33.0"
21+
aws-config = "0.56.1"
22+
tokio = { version = "1.33.0", features = ["macros"] }
23+
tracing = { version = "0.1.40", features = ["log"] }
24+
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["fmt"] }
2425

2526

examples/http-dynamodb/src/main.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use aws_sdk_dynamodb::model::AttributeValue;
2-
use aws_sdk_dynamodb::{Client, Error as OtherError};
1+
use aws_sdk_dynamodb::{Client};
32
use lambda_http::{run, service_fn, Body, Error, Request, Response};
3+
use serde::{Deserialize, Serialize};
4+
use serde_dynamo::to_attribute_value;
45
use tracing::info;
56

6-
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
7+
#[derive(Clone, Debug, Serialize, Deserialize)]
78
pub struct Item {
89
pub p_type: String,
910
pub age: String,
@@ -76,12 +77,12 @@ async fn main() -> Result<(), Error> {
7677

7778
// Add an item to a table.
7879
// snippet-start:[dynamodb.rust.add-item]
79-
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), OtherError> {
80-
let user_av = AttributeValue::S(item.username);
81-
let type_av = AttributeValue::S(item.p_type);
82-
let age_av = AttributeValue::S(item.age);
83-
let first_av = AttributeValue::S(item.first);
84-
let last_av = AttributeValue::S(item.last);
80+
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), Error> {
81+
let user_av = to_attribute_value(item.username)?;
82+
let type_av = to_attribute_value(item.p_type)?;
83+
let age_av = to_attribute_value(item.age)?;
84+
let first_av = to_attribute_value(item.first)?;
85+
let last_av = to_attribute_value(item.last)?;
8586

8687
let request = client
8788
.put_item()

0 commit comments

Comments
 (0)