aws_sdk_codedeploy/protocol_serde/
shape_zonal_config.rs1pub fn ser_zonal_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::ZonalConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.first_zone_monitor_duration_in_seconds {
7 object.key("firstZoneMonitorDurationInSeconds").number(
8 #[allow(clippy::useless_conversion)]
9 ::aws_smithy_types::Number::NegInt((*var_1).into()),
10 );
11 }
12 if let Some(var_2) = &input.monitor_duration_in_seconds {
13 object.key("monitorDurationInSeconds").number(
14 #[allow(clippy::useless_conversion)]
15 ::aws_smithy_types::Number::NegInt((*var_2).into()),
16 );
17 }
18 if let Some(var_3) = &input.minimum_healthy_hosts_per_zone {
19 #[allow(unused_mut)]
20 let mut object_4 = object.key("minimumHealthyHostsPerZone").start_object();
21 crate::protocol_serde::shape_minimum_healthy_hosts_per_zone::ser_minimum_healthy_hosts_per_zone(&mut object_4, var_3)?;
22 object_4.finish();
23 }
24 Ok(())
25}
26
27pub(crate) fn de_zonal_config<'a, I>(
28 tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::ZonalConfig>, ::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::ZonalConfigBuilder::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 "firstZoneMonitorDurationInSeconds" => {
43 builder = builder.set_first_zone_monitor_duration_in_seconds(
44 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
45 .map(i64::try_from)
46 .transpose()?,
47 );
48 }
49 "monitorDurationInSeconds" => {
50 builder = builder.set_monitor_duration_in_seconds(
51 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
52 .map(i64::try_from)
53 .transpose()?,
54 );
55 }
56 "minimumHealthyHostsPerZone" => {
57 builder = builder.set_minimum_healthy_hosts_per_zone(
58 crate::protocol_serde::shape_minimum_healthy_hosts_per_zone::de_minimum_healthy_hosts_per_zone(tokens)?,
59 );
60 }
61 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
62 },
63 other => {
64 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
65 "expected object key or end object, found: {:?}",
66 other
67 )))
68 }
69 }
70 }
71 Ok(Some(builder.build()))
72 }
73 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
74 "expected start object or null",
75 )),
76 }
77}