aws_sdk_backup/protocol_serde/
shape_backup_selection.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_backup_selection(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::BackupSelection,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("SelectionName").string(input.selection_name.as_str());
8    }
9    {
10        object.key("IamRoleArn").string(input.iam_role_arn.as_str());
11    }
12    if let Some(var_1) = &input.resources {
13        let mut array_2 = object.key("Resources").start_array();
14        for item_3 in var_1 {
15            {
16                array_2.value().string(item_3.as_str());
17            }
18        }
19        array_2.finish();
20    }
21    if let Some(var_4) = &input.list_of_tags {
22        let mut array_5 = object.key("ListOfTags").start_array();
23        for item_6 in var_4 {
24            {
25                #[allow(unused_mut)]
26                let mut object_7 = array_5.value().start_object();
27                crate::protocol_serde::shape_condition::ser_condition(&mut object_7, item_6)?;
28                object_7.finish();
29            }
30        }
31        array_5.finish();
32    }
33    if let Some(var_8) = &input.not_resources {
34        let mut array_9 = object.key("NotResources").start_array();
35        for item_10 in var_8 {
36            {
37                array_9.value().string(item_10.as_str());
38            }
39        }
40        array_9.finish();
41    }
42    if let Some(var_11) = &input.conditions {
43        #[allow(unused_mut)]
44        let mut object_12 = object.key("Conditions").start_object();
45        crate::protocol_serde::shape_conditions::ser_conditions(&mut object_12, var_11)?;
46        object_12.finish();
47    }
48    Ok(())
49}
50
51pub(crate) fn de_backup_selection<'a, I>(
52    tokens: &mut ::std::iter::Peekable<I>,
53) -> ::std::result::Result<Option<crate::types::BackupSelection>, ::aws_smithy_json::deserialize::error::DeserializeError>
54where
55    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
56{
57    match tokens.next().transpose()? {
58        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
59        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
60            #[allow(unused_mut)]
61            let mut builder = crate::types::builders::BackupSelectionBuilder::default();
62            loop {
63                match tokens.next().transpose()? {
64                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
65                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
66                        "SelectionName" => {
67                            builder = builder.set_selection_name(
68                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
69                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
70                                    .transpose()?,
71                            );
72                        }
73                        "IamRoleArn" => {
74                            builder = builder.set_iam_role_arn(
75                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
76                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
77                                    .transpose()?,
78                            );
79                        }
80                        "Resources" => {
81                            builder = builder.set_resources(crate::protocol_serde::shape_resource_arns::de_resource_arns(tokens)?);
82                        }
83                        "ListOfTags" => {
84                            builder = builder.set_list_of_tags(crate::protocol_serde::shape_list_of_tags::de_list_of_tags(tokens)?);
85                        }
86                        "NotResources" => {
87                            builder = builder.set_not_resources(crate::protocol_serde::shape_resource_arns::de_resource_arns(tokens)?);
88                        }
89                        "Conditions" => {
90                            builder = builder.set_conditions(crate::protocol_serde::shape_conditions::de_conditions(tokens)?);
91                        }
92                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
93                    },
94                    other => {
95                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
96                            "expected object key or end object, found: {:?}",
97                            other
98                        )))
99                    }
100                }
101            }
102            Ok(Some(crate::serde_util::backup_selection_correct_errors(builder).build().map_err(
103                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
104            )?))
105        }
106        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
107            "expected start object or null",
108        )),
109    }
110}