aws_sdk_lexmodelsv2/protocol_serde/
shape_text_log_setting.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_text_log_setting(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::TextLogSetting,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("enabled").boolean(input.enabled);
8    }
9    if let Some(var_1) = &input.destination {
10        #[allow(unused_mut)]
11        let mut object_2 = object.key("destination").start_object();
12        crate::protocol_serde::shape_text_log_destination::ser_text_log_destination(&mut object_2, var_1)?;
13        object_2.finish();
14    }
15    if let Some(var_3) = &input.selective_logging_enabled {
16        object.key("selectiveLoggingEnabled").boolean(*var_3);
17    }
18    Ok(())
19}
20
21pub(crate) fn de_text_log_setting<'a, I>(
22    tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::TextLogSetting>, ::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::TextLogSettingBuilder::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                        "enabled" => {
37                            builder = builder.set_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
38                        }
39                        "destination" => {
40                            builder = builder.set_destination(crate::protocol_serde::shape_text_log_destination::de_text_log_destination(tokens)?);
41                        }
42                        "selectiveLoggingEnabled" => {
43                            builder =
44                                builder.set_selective_logging_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
45                        }
46                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
47                    },
48                    other => {
49                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
50                            "expected object key or end object, found: {:?}",
51                            other
52                        )))
53                    }
54                }
55            }
56            Ok(Some(crate::serde_util::text_log_setting_correct_errors(builder).build()))
57        }
58        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
59            "expected start object or null",
60        )),
61    }
62}