aws_sdk_sagemaker/protocol_serde/
shape_container_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_container_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ContainerConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.container_arguments {
7        let mut array_2 = object.key("ContainerArguments").start_array();
8        for item_3 in var_1 {
9            {
10                array_2.value().string(item_3.as_str());
11            }
12        }
13        array_2.finish();
14    }
15    if let Some(var_4) = &input.container_entrypoint {
16        let mut array_5 = object.key("ContainerEntrypoint").start_array();
17        for item_6 in var_4 {
18            {
19                array_5.value().string(item_6.as_str());
20            }
21        }
22        array_5.finish();
23    }
24    if let Some(var_7) = &input.container_environment_variables {
25        #[allow(unused_mut)]
26        let mut object_8 = object.key("ContainerEnvironmentVariables").start_object();
27        for (key_9, value_10) in var_7 {
28            {
29                object_8.key(key_9.as_str()).string(value_10.as_str());
30            }
31        }
32        object_8.finish();
33    }
34    Ok(())
35}
36
37pub(crate) fn de_container_config<'a, I>(
38    tokens: &mut ::std::iter::Peekable<I>,
39) -> ::std::result::Result<Option<crate::types::ContainerConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
40where
41    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
42{
43    match tokens.next().transpose()? {
44        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
45        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
46            #[allow(unused_mut)]
47            let mut builder = crate::types::builders::ContainerConfigBuilder::default();
48            loop {
49                match tokens.next().transpose()? {
50                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
51                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
52                        "ContainerArguments" => {
53                            builder = builder.set_container_arguments(
54                                crate::protocol_serde::shape_custom_image_container_arguments::de_custom_image_container_arguments(tokens)?,
55                            );
56                        }
57                        "ContainerEntrypoint" => {
58                            builder = builder.set_container_entrypoint(
59                                crate::protocol_serde::shape_custom_image_container_entrypoint::de_custom_image_container_entrypoint(tokens)?,
60                            );
61                        }
62                        "ContainerEnvironmentVariables" => {
63                            builder = builder.set_container_environment_variables(
64                                    crate::protocol_serde::shape_custom_image_container_environment_variables::de_custom_image_container_environment_variables(tokens)?
65                                );
66                        }
67                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
68                    },
69                    other => {
70                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
71                            "expected object key or end object, found: {:?}",
72                            other
73                        )))
74                    }
75                }
76            }
77            Ok(Some(builder.build()))
78        }
79        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
80            "expected start object or null",
81        )),
82    }
83}