aws_sdk_emrcontainers/protocol_serde/
shape_retry_policy_configuration.rs1pub fn ser_retry_policy_configuration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::RetryPolicyConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("maxAttempts").number(
8 #[allow(clippy::useless_conversion)]
9 ::aws_smithy_types::Number::NegInt((input.max_attempts).into()),
10 );
11 }
12 Ok(())
13}
14
15pub(crate) fn de_retry_policy_configuration<'a, I>(
16 tokens: &mut ::std::iter::Peekable<I>,
17) -> ::std::result::Result<Option<crate::types::RetryPolicyConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
18where
19 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
20{
21 match tokens.next().transpose()? {
22 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
23 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
24 #[allow(unused_mut)]
25 let mut builder = crate::types::builders::RetryPolicyConfigurationBuilder::default();
26 loop {
27 match tokens.next().transpose()? {
28 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
29 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
30 "maxAttempts" => {
31 builder = builder.set_max_attempts(
32 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
33 .map(i32::try_from)
34 .transpose()?,
35 );
36 }
37 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
38 },
39 other => {
40 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
41 "expected object key or end object, found: {other:?}"
42 )))
43 }
44 }
45 }
46 Ok(Some(
47 crate::serde_util::retry_policy_configuration_correct_errors(builder)
48 .build()
49 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
50 ))
51 }
52 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
53 "expected start object or null",
54 )),
55 }
56}