aws_sdk_apprunner/protocol_serde/
shape_code_configuration_values.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_code_configuration_values(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::CodeConfigurationValues,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("Runtime").string(input.runtime.as_str());
8    }
9    if let Some(var_1) = &input.build_command {
10        object.key("BuildCommand").string(var_1.as_str());
11    }
12    if let Some(var_2) = &input.start_command {
13        object.key("StartCommand").string(var_2.as_str());
14    }
15    if let Some(var_3) = &input.port {
16        object.key("Port").string(var_3.as_str());
17    }
18    if let Some(var_4) = &input.runtime_environment_variables {
19        #[allow(unused_mut)]
20        let mut object_5 = object.key("RuntimeEnvironmentVariables").start_object();
21        for (key_6, value_7) in var_4 {
22            {
23                object_5.key(key_6.as_str()).string(value_7.as_str());
24            }
25        }
26        object_5.finish();
27    }
28    if let Some(var_8) = &input.runtime_environment_secrets {
29        #[allow(unused_mut)]
30        let mut object_9 = object.key("RuntimeEnvironmentSecrets").start_object();
31        for (key_10, value_11) in var_8 {
32            {
33                object_9.key(key_10.as_str()).string(value_11.as_str());
34            }
35        }
36        object_9.finish();
37    }
38    Ok(())
39}
40
41pub(crate) fn de_code_configuration_values<'a, I>(
42    tokens: &mut ::std::iter::Peekable<I>,
43) -> ::std::result::Result<Option<crate::types::CodeConfigurationValues>, ::aws_smithy_json::deserialize::error::DeserializeError>
44where
45    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
46{
47    match tokens.next().transpose()? {
48        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
49        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
50            #[allow(unused_mut)]
51            let mut builder = crate::types::builders::CodeConfigurationValuesBuilder::default();
52            loop {
53                match tokens.next().transpose()? {
54                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
55                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
56                        "Runtime" => {
57                            builder = builder.set_runtime(
58                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59                                    .map(|s| s.to_unescaped().map(|u| crate::types::Runtime::from(u.as_ref())))
60                                    .transpose()?,
61                            );
62                        }
63                        "BuildCommand" => {
64                            builder = builder.set_build_command(
65                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
66                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
67                                    .transpose()?,
68                            );
69                        }
70                        "StartCommand" => {
71                            builder = builder.set_start_command(
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                        "Port" => {
78                            builder = builder.set_port(
79                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
80                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
81                                    .transpose()?,
82                            );
83                        }
84                        "RuntimeEnvironmentVariables" => {
85                            builder = builder.set_runtime_environment_variables(
86                                crate::protocol_serde::shape_runtime_environment_variables::de_runtime_environment_variables(tokens)?,
87                            );
88                        }
89                        "RuntimeEnvironmentSecrets" => {
90                            builder = builder.set_runtime_environment_secrets(
91                                crate::protocol_serde::shape_runtime_environment_secrets::de_runtime_environment_secrets(tokens)?,
92                            );
93                        }
94                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
95                    },
96                    other => {
97                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
98                            "expected object key or end object, found: {:?}",
99                            other
100                        )))
101                    }
102                }
103            }
104            Ok(Some(
105                crate::serde_util::code_configuration_values_correct_errors(builder)
106                    .build()
107                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
108            ))
109        }
110        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
111            "expected start object or null",
112        )),
113    }
114}