aws_sdk_sagemaker/protocol_serde/
shape_output_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_output_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::OutputConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.s3_output_location {
7        object.key("S3OutputLocation").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.target_device {
10        object.key("TargetDevice").string(var_2.as_str());
11    }
12    if let Some(var_3) = &input.target_platform {
13        #[allow(unused_mut)]
14        let mut object_4 = object.key("TargetPlatform").start_object();
15        crate::protocol_serde::shape_target_platform::ser_target_platform(&mut object_4, var_3)?;
16        object_4.finish();
17    }
18    if let Some(var_5) = &input.compiler_options {
19        object.key("CompilerOptions").string(var_5.as_str());
20    }
21    if let Some(var_6) = &input.kms_key_id {
22        object.key("KmsKeyId").string(var_6.as_str());
23    }
24    Ok(())
25}
26
27pub(crate) fn de_output_config<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::OutputConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33    match tokens.next().transpose()? {
34        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36            #[allow(unused_mut)]
37            let mut builder = crate::types::builders::OutputConfigBuilder::default();
38            loop {
39                match tokens.next().transpose()? {
40                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42                        "S3OutputLocation" => {
43                            builder = builder.set_s3_output_location(
44                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
46                                    .transpose()?,
47                            );
48                        }
49                        "TargetDevice" => {
50                            builder = builder.set_target_device(
51                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52                                    .map(|s| s.to_unescaped().map(|u| crate::types::TargetDevice::from(u.as_ref())))
53                                    .transpose()?,
54                            );
55                        }
56                        "TargetPlatform" => {
57                            builder = builder.set_target_platform(crate::protocol_serde::shape_target_platform::de_target_platform(tokens)?);
58                        }
59                        "CompilerOptions" => {
60                            builder = builder.set_compiler_options(
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                        "KmsKeyId" => {
67                            builder = builder.set_kms_key_id(
68                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
69                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
70                                    .transpose()?,
71                            );
72                        }
73                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
74                    },
75                    other => {
76                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
77                            "expected object key or end object, found: {:?}",
78                            other
79                        )))
80                    }
81                }
82            }
83            Ok(Some(crate::serde_util::output_config_correct_errors(builder).build()))
84        }
85        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
86            "expected start object or null",
87        )),
88    }
89}