aws_sdk_sagemaker/protocol_serde/
shape_processing_cluster_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_processing_cluster_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ProcessingClusterConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.instance_count {
7        object.key("InstanceCount").number(
8            #[allow(clippy::useless_conversion)]
9            ::aws_smithy_types::Number::NegInt((*var_1).into()),
10        );
11    }
12    if let Some(var_2) = &input.instance_type {
13        object.key("InstanceType").string(var_2.as_str());
14    }
15    if let Some(var_3) = &input.volume_size_in_gb {
16        object.key("VolumeSizeInGB").number(
17            #[allow(clippy::useless_conversion)]
18            ::aws_smithy_types::Number::NegInt((*var_3).into()),
19        );
20    }
21    if let Some(var_4) = &input.volume_kms_key_id {
22        object.key("VolumeKmsKeyId").string(var_4.as_str());
23    }
24    Ok(())
25}
26
27pub(crate) fn de_processing_cluster_config<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::ProcessingClusterConfig>, ::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::ProcessingClusterConfigBuilder::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                        "InstanceCount" => {
43                            builder = builder.set_instance_count(
44                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
45                                    .map(i32::try_from)
46                                    .transpose()?,
47                            );
48                        }
49                        "InstanceType" => {
50                            builder = builder.set_instance_type(
51                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52                                    .map(|s| s.to_unescaped().map(|u| crate::types::ProcessingInstanceType::from(u.as_ref())))
53                                    .transpose()?,
54                            );
55                        }
56                        "VolumeSizeInGB" => {
57                            builder = builder.set_volume_size_in_gb(
58                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
59                                    .map(i32::try_from)
60                                    .transpose()?,
61                            );
62                        }
63                        "VolumeKmsKeyId" => {
64                            builder = builder.set_volume_kms_key_id(
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                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
71                    },
72                    other => {
73                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
74                            "expected object key or end object, found: {:?}",
75                            other
76                        )))
77                    }
78                }
79            }
80            Ok(Some(crate::serde_util::processing_cluster_config_correct_errors(builder).build()))
81        }
82        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
83            "expected start object or null",
84        )),
85    }
86}