aws_sdk_dlm/protocol_serde/
shape_script.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_script(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::Script,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.stages {
7        let mut array_2 = object.key("Stages").start_array();
8        for item_3 in var_1 {
9            {
10                array_2.value().string(item_3.as_str());
11            }
12        }
13        array_2.finish();
14    }
15    if let Some(var_4) = &input.execution_handler_service {
16        object.key("ExecutionHandlerService").string(var_4.as_str());
17    }
18    if let Some(var_5) = &input.execution_handler {
19        object.key("ExecutionHandler").string(var_5.as_str());
20    }
21    if let Some(var_6) = &input.execute_operation_on_script_failure {
22        object.key("ExecuteOperationOnScriptFailure").boolean(*var_6);
23    }
24    if let Some(var_7) = &input.execution_timeout {
25        object.key("ExecutionTimeout").number(
26            #[allow(clippy::useless_conversion)]
27            ::aws_smithy_types::Number::NegInt((*var_7).into()),
28        );
29    }
30    if let Some(var_8) = &input.maximum_retry_count {
31        object.key("MaximumRetryCount").number(
32            #[allow(clippy::useless_conversion)]
33            ::aws_smithy_types::Number::NegInt((*var_8).into()),
34        );
35    }
36    Ok(())
37}
38
39pub(crate) fn de_script<'a, I>(
40    tokens: &mut ::std::iter::Peekable<I>,
41) -> ::std::result::Result<Option<crate::types::Script>, ::aws_smithy_json::deserialize::error::DeserializeError>
42where
43    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
44{
45    match tokens.next().transpose()? {
46        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
47        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
48            #[allow(unused_mut)]
49            let mut builder = crate::types::builders::ScriptBuilder::default();
50            loop {
51                match tokens.next().transpose()? {
52                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
53                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
54                        "Stages" => {
55                            builder = builder.set_stages(crate::protocol_serde::shape_stages_list::de_stages_list(tokens)?);
56                        }
57                        "ExecutionHandlerService" => {
58                            builder = builder.set_execution_handler_service(
59                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
60                                    .map(|s| s.to_unescaped().map(|u| crate::types::ExecutionHandlerServiceValues::from(u.as_ref())))
61                                    .transpose()?,
62                            );
63                        }
64                        "ExecutionHandler" => {
65                            builder = builder.set_execution_handler(
66                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
67                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
68                                    .transpose()?,
69                            );
70                        }
71                        "ExecuteOperationOnScriptFailure" => {
72                            builder = builder
73                                .set_execute_operation_on_script_failure(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
74                        }
75                        "ExecutionTimeout" => {
76                            builder = builder.set_execution_timeout(
77                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
78                                    .map(i32::try_from)
79                                    .transpose()?,
80                            );
81                        }
82                        "MaximumRetryCount" => {
83                            builder = builder.set_maximum_retry_count(
84                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
85                                    .map(i32::try_from)
86                                    .transpose()?,
87                            );
88                        }
89                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
90                    },
91                    other => {
92                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
93                            "expected object key or end object, found: {:?}",
94                            other
95                        )))
96                    }
97                }
98            }
99            Ok(Some(crate::serde_util::script_correct_errors(builder).build()))
100        }
101        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
102            "expected start object or null",
103        )),
104    }
105}