Skip to main content

aws_sdk_config/protocol_serde/
shape_custom_policy_details.rs

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