aws_sdk_appmesh/protocol_serde/
shape_virtual_gateway_health_check_policy.rs1pub fn ser_virtual_gateway_health_check_policy(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::VirtualGatewayHealthCheckPolicy,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("timeoutMillis").number(
8            #[allow(clippy::useless_conversion)]
9            ::aws_smithy_types::Number::NegInt((input.timeout_millis).into()),
10        );
11    }
12    {
13        object.key("intervalMillis").number(
14            #[allow(clippy::useless_conversion)]
15            ::aws_smithy_types::Number::NegInt((input.interval_millis).into()),
16        );
17    }
18    {
19        object.key("protocol").string(input.protocol.as_str());
20    }
21    if let Some(var_1) = &input.port {
22        object.key("port").number(
23            #[allow(clippy::useless_conversion)]
24            ::aws_smithy_types::Number::NegInt((*var_1).into()),
25        );
26    }
27    if let Some(var_2) = &input.path {
28        object.key("path").string(var_2.as_str());
29    }
30    {
31        object.key("healthyThreshold").number(
32            #[allow(clippy::useless_conversion)]
33            ::aws_smithy_types::Number::NegInt((input.healthy_threshold).into()),
34        );
35    }
36    {
37        object.key("unhealthyThreshold").number(
38            #[allow(clippy::useless_conversion)]
39            ::aws_smithy_types::Number::NegInt((input.unhealthy_threshold).into()),
40        );
41    }
42    Ok(())
43}
44
45pub(crate) fn de_virtual_gateway_health_check_policy<'a, I>(
46    tokens: &mut ::std::iter::Peekable<I>,
47) -> ::std::result::Result<Option<crate::types::VirtualGatewayHealthCheckPolicy>, ::aws_smithy_json::deserialize::error::DeserializeError>
48where
49    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
50{
51    match tokens.next().transpose()? {
52        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
53        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
54            #[allow(unused_mut)]
55            let mut builder = crate::types::builders::VirtualGatewayHealthCheckPolicyBuilder::default();
56            loop {
57                match tokens.next().transpose()? {
58                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
59                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
60                        "timeoutMillis" => {
61                            builder = builder.set_timeout_millis(
62                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
63                                    .map(i64::try_from)
64                                    .transpose()?,
65                            );
66                        }
67                        "intervalMillis" => {
68                            builder = builder.set_interval_millis(
69                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
70                                    .map(i64::try_from)
71                                    .transpose()?,
72                            );
73                        }
74                        "protocol" => {
75                            builder = builder.set_protocol(
76                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
77                                    .map(|s| s.to_unescaped().map(|u| crate::types::VirtualGatewayPortProtocol::from(u.as_ref())))
78                                    .transpose()?,
79                            );
80                        }
81                        "port" => {
82                            builder = builder.set_port(
83                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
84                                    .map(i32::try_from)
85                                    .transpose()?,
86                            );
87                        }
88                        "path" => {
89                            builder = builder.set_path(
90                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
91                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
92                                    .transpose()?,
93                            );
94                        }
95                        "healthyThreshold" => {
96                            builder = builder.set_healthy_threshold(
97                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
98                                    .map(i32::try_from)
99                                    .transpose()?,
100                            );
101                        }
102                        "unhealthyThreshold" => {
103                            builder = builder.set_unhealthy_threshold(
104                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
105                                    .map(i32::try_from)
106                                    .transpose()?,
107                            );
108                        }
109                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
110                    },
111                    other => {
112                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
113                            "expected object key or end object, found: {:?}",
114                            other
115                        )))
116                    }
117                }
118            }
119            Ok(Some(
120                crate::serde_util::virtual_gateway_health_check_policy_correct_errors(builder)
121                    .build()
122                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
123            ))
124        }
125        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
126            "expected start object or null",
127        )),
128    }
129}