aws_sdk_ecs/protocol_serde/
shape_log_configuration.rs1pub fn ser_log_configuration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::LogConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("logDriver").string(input.log_driver.as_str());
8 }
9 if let Some(var_1) = &input.options {
10 #[allow(unused_mut)]
11 let mut object_2 = object.key("options").start_object();
12 for (key_3, value_4) in var_1 {
13 {
14 object_2.key(key_3.as_str()).string(value_4.as_str());
15 }
16 }
17 object_2.finish();
18 }
19 if let Some(var_5) = &input.secret_options {
20 let mut array_6 = object.key("secretOptions").start_array();
21 for item_7 in var_5 {
22 {
23 #[allow(unused_mut)]
24 let mut object_8 = array_6.value().start_object();
25 crate::protocol_serde::shape_secret::ser_secret(&mut object_8, item_7)?;
26 object_8.finish();
27 }
28 }
29 array_6.finish();
30 }
31 Ok(())
32}
33
34pub(crate) fn de_log_configuration<'a, I>(
35 tokens: &mut ::std::iter::Peekable<I>,
36) -> ::std::result::Result<Option<crate::types::LogConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
37where
38 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
39{
40 match tokens.next().transpose()? {
41 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
42 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
43 #[allow(unused_mut)]
44 let mut builder = crate::types::builders::LogConfigurationBuilder::default();
45 loop {
46 match tokens.next().transpose()? {
47 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
48 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
49 "logDriver" => {
50 builder = builder.set_log_driver(
51 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52 .map(|s| s.to_unescaped().map(|u| crate::types::LogDriver::from(u.as_ref())))
53 .transpose()?,
54 );
55 }
56 "options" => {
57 builder = builder
58 .set_options(crate::protocol_serde::shape_log_configuration_options_map::de_log_configuration_options_map(tokens)?);
59 }
60 "secretOptions" => {
61 builder = builder.set_secret_options(crate::protocol_serde::shape_secret_list::de_secret_list(tokens)?);
62 }
63 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
64 },
65 other => {
66 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
67 "expected object key or end object, found: {:?}",
68 other
69 )))
70 }
71 }
72 }
73 Ok(Some(crate::serde_util::log_configuration_correct_errors(builder).build().map_err(
74 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
75 )?))
76 }
77 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
78 "expected start object or null",
79 )),
80 }
81}