aws_sdk_codepipeline/protocol_serde/
shape_failure_conditions.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_failure_conditions(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::FailureConditions,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.result {
7        object.key("result").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.retry_configuration {
10        #[allow(unused_mut)]
11        let mut object_3 = object.key("retryConfiguration").start_object();
12        crate::protocol_serde::shape_retry_configuration::ser_retry_configuration(&mut object_3, var_2)?;
13        object_3.finish();
14    }
15    if let Some(var_4) = &input.conditions {
16        let mut array_5 = object.key("conditions").start_array();
17        for item_6 in var_4 {
18            {
19                #[allow(unused_mut)]
20                let mut object_7 = array_5.value().start_object();
21                crate::protocol_serde::shape_condition::ser_condition(&mut object_7, item_6)?;
22                object_7.finish();
23            }
24        }
25        array_5.finish();
26    }
27    Ok(())
28}
29
30pub(crate) fn de_failure_conditions<'a, I>(
31    tokens: &mut ::std::iter::Peekable<I>,
32) -> ::std::result::Result<Option<crate::types::FailureConditions>, ::aws_smithy_json::deserialize::error::DeserializeError>
33where
34    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
35{
36    match tokens.next().transpose()? {
37        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
38        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
39            #[allow(unused_mut)]
40            let mut builder = crate::types::builders::FailureConditionsBuilder::default();
41            loop {
42                match tokens.next().transpose()? {
43                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
44                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
45                        "result" => {
46                            builder = builder.set_result(
47                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
48                                    .map(|s| s.to_unescaped().map(|u| crate::types::Result::from(u.as_ref())))
49                                    .transpose()?,
50                            );
51                        }
52                        "retryConfiguration" => {
53                            builder =
54                                builder.set_retry_configuration(crate::protocol_serde::shape_retry_configuration::de_retry_configuration(tokens)?);
55                        }
56                        "conditions" => {
57                            builder = builder.set_conditions(crate::protocol_serde::shape_condition_list::de_condition_list(tokens)?);
58                        }
59                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
60                    },
61                    other => {
62                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
63                            "expected object key or end object, found: {:?}",
64                            other
65                        )))
66                    }
67                }
68            }
69            Ok(Some(builder.build()))
70        }
71        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
72            "expected start object or null",
73        )),
74    }
75}