aws_sdk_imagebuilder/protocol_serde/
shape_image_recipe.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_image_recipe<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::ImageRecipe>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::ImageRecipeBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "arn" => {
18                            builder = builder.set_arn(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "type" => {
25                            builder = builder.set_type(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| crate::types::ImageType::from(u.as_ref())))
28                                    .transpose()?,
29                            );
30                        }
31                        "name" => {
32                            builder = builder.set_name(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "description" => {
39                            builder = builder.set_description(
40                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
41                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
42                                    .transpose()?,
43                            );
44                        }
45                        "platform" => {
46                            builder = builder.set_platform(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| crate::types::Platform::from(u.as_ref())))
49                                    .transpose()?,
50                            );
51                        }
52                        "owner" => {
53                            builder = builder.set_owner(
54                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
55                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
56                                    .transpose()?,
57                            );
58                        }
59                        "version" => {
60                            builder = builder.set_version(
61                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
62                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
63                                    .transpose()?,
64                            );
65                        }
66                        "components" => {
67                            builder = builder
68                                .set_components(crate::protocol_serde::shape_component_configuration_list::de_component_configuration_list(tokens)?);
69                        }
70                        "parentImage" => {
71                            builder = builder.set_parent_image(
72                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
74                                    .transpose()?,
75                            );
76                        }
77                        "blockDeviceMappings" => {
78                            builder = builder.set_block_device_mappings(
79                                crate::protocol_serde::shape_instance_block_device_mappings::de_instance_block_device_mappings(tokens)?,
80                            );
81                        }
82                        "dateCreated" => {
83                            builder = builder.set_date_created(
84                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
85                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
86                                    .transpose()?,
87                            );
88                        }
89                        "tags" => {
90                            builder = builder.set_tags(crate::protocol_serde::shape_tag_map::de_tag_map(tokens)?);
91                        }
92                        "workingDirectory" => {
93                            builder = builder.set_working_directory(
94                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
95                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
96                                    .transpose()?,
97                            );
98                        }
99                        "additionalInstanceConfiguration" => {
100                            builder = builder.set_additional_instance_configuration(
101                                crate::protocol_serde::shape_additional_instance_configuration::de_additional_instance_configuration(tokens)?,
102                            );
103                        }
104                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
105                    },
106                    other => {
107                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
108                            "expected object key or end object, found: {:?}",
109                            other
110                        )))
111                    }
112                }
113            }
114            Ok(Some(builder.build()))
115        }
116        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
117            "expected start object or null",
118        )),
119    }
120}