You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-22Lines changed: 19 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -554,37 +554,34 @@ See the [examples directory](https://github.com/aws/aws-lambda-rust-runtime/tree
554
554
To serialize and deserialize events and responses, we suggest using the [`serde`](https://github.com/serde-rs/serde) library. To receive custom events, annotate your structure with Serde's macros:
555
555
556
556
```rust,no_run
557
-
use serde::{Serialize, Deserialize};
558
-
use serde_json::json;
559
-
use std::error::Error;
557
+
use lambda_runtime::{service_fn, Error, LambdaEvent};
558
+
use serde::{Deserialize, Serialize};
560
559
561
-
#[derive(Serialize, Deserialize)]
560
+
#[derive(Debug, Deserialize)]
562
561
pub struct NewIceCreamEvent {
563
-
pub flavors: Vec<String>,
562
+
pub flavors: Vec<String>,
564
563
}
565
564
566
-
#[derive(Serialize, Deserialize)]
565
+
#[derive(Serialize)]
567
566
pub struct NewIceCreamResponse {
568
-
pub flavors_added_count: usize,
567
+
pub flavors_added_count: usize,
569
568
}
570
569
571
-
fn main() -> Result<(), Box<Error>> {
572
-
let flavors = json!({
573
-
"flavors": [
574
-
"Nocciola",
575
-
"抹茶",
576
-
"आम"
577
-
]
578
-
});
579
-
580
-
let event: NewIceCreamEvent = serde_json::from_value(flavors)?;
0 commit comments