aws_sdk_ecs/protocol_serde/
shape_proxy_configuration.rs1pub fn ser_proxy_configuration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::ProxyConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.r#type {
7 object.key("type").string(var_1.as_str());
8 }
9 {
10 object.key("containerName").string(input.container_name.as_str());
11 }
12 if let Some(var_2) = &input.properties {
13 let mut array_3 = object.key("properties").start_array();
14 for item_4 in var_2 {
15 {
16 #[allow(unused_mut)]
17 let mut object_5 = array_3.value().start_object();
18 crate::protocol_serde::shape_key_value_pair::ser_key_value_pair(&mut object_5, item_4)?;
19 object_5.finish();
20 }
21 }
22 array_3.finish();
23 }
24 Ok(())
25}
26
27pub(crate) fn de_proxy_configuration<'a, I>(
28 tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::ProxyConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36 #[allow(unused_mut)]
37 let mut builder = crate::types::builders::ProxyConfigurationBuilder::default();
38 loop {
39 match tokens.next().transpose()? {
40 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42 "type" => {
43 builder = builder.set_type(
44 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45 .map(|s| s.to_unescaped().map(|u| crate::types::ProxyConfigurationType::from(u.as_ref())))
46 .transpose()?,
47 );
48 }
49 "containerName" => {
50 builder = builder.set_container_name(
51 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
53 .transpose()?,
54 );
55 }
56 "properties" => {
57 builder = builder.set_properties(
58 crate::protocol_serde::shape_proxy_configuration_properties::de_proxy_configuration_properties(tokens)?,
59 );
60 }
61 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
62 },
63 other => {
64 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
65 "expected object key or end object, found: {:?}",
66 other
67 )))
68 }
69 }
70 }
71 Ok(Some(crate::serde_util::proxy_configuration_correct_errors(builder).build().map_err(
72 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
73 )?))
74 }
75 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
76 "expected start object or null",
77 )),
78 }
79}