aws_sdk_apprunner/protocol_serde/
shape_image_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_image_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ImageConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.runtime_environment_variables {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("RuntimeEnvironmentVariables").start_object();
9        for (key_3, value_4) in var_1 {
10            {
11                object_2.key(key_3.as_str()).string(value_4.as_str());
12            }
13        }
14        object_2.finish();
15    }
16    if let Some(var_5) = &input.start_command {
17        object.key("StartCommand").string(var_5.as_str());
18    }
19    if let Some(var_6) = &input.port {
20        object.key("Port").string(var_6.as_str());
21    }
22    if let Some(var_7) = &input.runtime_environment_secrets {
23        #[allow(unused_mut)]
24        let mut object_8 = object.key("RuntimeEnvironmentSecrets").start_object();
25        for (key_9, value_10) in var_7 {
26            {
27                object_8.key(key_9.as_str()).string(value_10.as_str());
28            }
29        }
30        object_8.finish();
31    }
32    Ok(())
33}
34
35pub(crate) fn de_image_configuration<'a, I>(
36    tokens: &mut ::std::iter::Peekable<I>,
37) -> ::std::result::Result<Option<crate::types::ImageConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
38where
39    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
40{
41    match tokens.next().transpose()? {
42        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
43        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
44            #[allow(unused_mut)]
45            let mut builder = crate::types::builders::ImageConfigurationBuilder::default();
46            loop {
47                match tokens.next().transpose()? {
48                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
49                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
50                        "RuntimeEnvironmentVariables" => {
51                            builder = builder.set_runtime_environment_variables(
52                                crate::protocol_serde::shape_runtime_environment_variables::de_runtime_environment_variables(tokens)?,
53                            );
54                        }
55                        "StartCommand" => {
56                            builder = builder.set_start_command(
57                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
58                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
59                                    .transpose()?,
60                            );
61                        }
62                        "Port" => {
63                            builder = builder.set_port(
64                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
65                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
66                                    .transpose()?,
67                            );
68                        }
69                        "RuntimeEnvironmentSecrets" => {
70                            builder = builder.set_runtime_environment_secrets(
71                                crate::protocol_serde::shape_runtime_environment_secrets::de_runtime_environment_secrets(tokens)?,
72                            );
73                        }
74                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
75                    },
76                    other => {
77                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
78                            "expected object key or end object, found: {:?}",
79                            other
80                        )))
81                    }
82                }
83            }
84            Ok(Some(builder.build()))
85        }
86        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
87            "expected start object or null",
88        )),
89    }
90}