aws_sdk_codestarconnections/protocol_serde/
shape_vpc_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_vpc_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::VpcConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("VpcId").string(input.vpc_id.as_str());
8    }
9    {
10        let mut array_1 = object.key("SubnetIds").start_array();
11        for item_2 in &input.subnet_ids {
12            {
13                array_1.value().string(item_2.as_str());
14            }
15        }
16        array_1.finish();
17    }
18    {
19        let mut array_3 = object.key("SecurityGroupIds").start_array();
20        for item_4 in &input.security_group_ids {
21            {
22                array_3.value().string(item_4.as_str());
23            }
24        }
25        array_3.finish();
26    }
27    if let Some(var_5) = &input.tls_certificate {
28        object.key("TlsCertificate").string(var_5.as_str());
29    }
30    Ok(())
31}
32
33pub(crate) fn de_vpc_configuration<'a, I>(
34    tokens: &mut ::std::iter::Peekable<I>,
35) -> ::std::result::Result<Option<crate::types::VpcConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
36where
37    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
38{
39    match tokens.next().transpose()? {
40        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
41        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
42            #[allow(unused_mut)]
43            let mut builder = crate::types::builders::VpcConfigurationBuilder::default();
44            loop {
45                match tokens.next().transpose()? {
46                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
47                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
48                        "VpcId" => {
49                            builder = builder.set_vpc_id(
50                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
51                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
52                                    .transpose()?,
53                            );
54                        }
55                        "SubnetIds" => {
56                            builder = builder.set_subnet_ids(crate::protocol_serde::shape_subnet_ids::de_subnet_ids(tokens)?);
57                        }
58                        "SecurityGroupIds" => {
59                            builder = builder.set_security_group_ids(crate::protocol_serde::shape_security_group_ids::de_security_group_ids(tokens)?);
60                        }
61                        "TlsCertificate" => {
62                            builder = builder.set_tls_certificate(
63                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
64                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
65                                    .transpose()?,
66                            );
67                        }
68                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
69                    },
70                    other => {
71                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
72                            "expected object key or end object, found: {:?}",
73                            other
74                        )))
75                    }
76                }
77            }
78            Ok(Some(crate::serde_util::vpc_configuration_correct_errors(builder).build().map_err(
79                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
80            )?))
81        }
82        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
83            "expected start object or null",
84        )),
85    }
86}