aws_sdk_sagemaker/protocol_serde/
shape_hyper_parameter_tuning_instance_config.rs1pub fn ser_hyper_parameter_tuning_instance_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::HyperParameterTuningInstanceConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.instance_type {
7 object.key("InstanceType").string(var_1.as_str());
8 }
9 if let Some(var_2) = &input.instance_count {
10 object.key("InstanceCount").number(
11 #[allow(clippy::useless_conversion)]
12 ::aws_smithy_types::Number::NegInt((*var_2).into()),
13 );
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 Ok(())
22}
23
24pub(crate) fn de_hyper_parameter_tuning_instance_config<'a, I>(
25 tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::HyperParameterTuningInstanceConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33 #[allow(unused_mut)]
34 let mut builder = crate::types::builders::HyperParameterTuningInstanceConfigBuilder::default();
35 loop {
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39 "InstanceType" => {
40 builder = builder.set_instance_type(
41 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42 .map(|s| s.to_unescaped().map(|u| crate::types::TrainingInstanceType::from(u.as_ref())))
43 .transpose()?,
44 );
45 }
46 "InstanceCount" => {
47 builder = builder.set_instance_count(
48 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
49 .map(i32::try_from)
50 .transpose()?,
51 );
52 }
53 "VolumeSizeInGB" => {
54 builder = builder.set_volume_size_in_gb(
55 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
56 .map(i32::try_from)
57 .transpose()?,
58 );
59 }
60 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
61 },
62 other => {
63 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
64 "expected object key or end object, found: {:?}",
65 other
66 )))
67 }
68 }
69 }
70 Ok(Some(
71 crate::serde_util::hyper_parameter_tuning_instance_config_correct_errors(builder).build(),
72 ))
73 }
74 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
75 "expected start object or null",
76 )),
77 }
78}