aws_sdk_datasync/protocol_serde/
shape_ec2_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_ec2_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::Ec2Config,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("SubnetArn").string(input.subnet_arn.as_str());
8    }
9    {
10        let mut array_1 = object.key("SecurityGroupArns").start_array();
11        for item_2 in &input.security_group_arns {
12            {
13                array_1.value().string(item_2.as_str());
14            }
15        }
16        array_1.finish();
17    }
18    Ok(())
19}
20
21pub(crate) fn de_ec2_config<'a, I>(
22    tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::Ec2Config>, ::aws_smithy_json::deserialize::error::DeserializeError>
24where
25    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
26{
27    match tokens.next().transpose()? {
28        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
29        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
30            #[allow(unused_mut)]
31            let mut builder = crate::types::builders::Ec2ConfigBuilder::default();
32            loop {
33                match tokens.next().transpose()? {
34                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
35                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
36                        "SubnetArn" => {
37                            builder = builder.set_subnet_arn(
38                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
39                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
40                                    .transpose()?,
41                            );
42                        }
43                        "SecurityGroupArns" => {
44                            builder = builder.set_security_group_arns(
45                                crate::protocol_serde::shape_ec2_security_group_arn_list::de_ec2_security_group_arn_list(tokens)?,
46                            );
47                        }
48                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
49                    },
50                    other => {
51                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
52                            "expected object key or end object, found: {:?}",
53                            other
54                        )))
55                    }
56                }
57            }
58            Ok(Some(crate::serde_util::ec2_config_correct_errors(builder).build().map_err(|err| {
59                ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
60            })?))
61        }
62        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
63            "expected start object or null",
64        )),
65    }
66}