aws_sdk_appsync/protocol_serde/
shape_event_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_event_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::EventConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        let mut array_1 = object.key("authProviders").start_array();
8        for item_2 in &input.auth_providers {
9            {
10                #[allow(unused_mut)]
11                let mut object_3 = array_1.value().start_object();
12                crate::protocol_serde::shape_auth_provider::ser_auth_provider(&mut object_3, item_2)?;
13                object_3.finish();
14            }
15        }
16        array_1.finish();
17    }
18    {
19        let mut array_4 = object.key("connectionAuthModes").start_array();
20        for item_5 in &input.connection_auth_modes {
21            {
22                #[allow(unused_mut)]
23                let mut object_6 = array_4.value().start_object();
24                crate::protocol_serde::shape_auth_mode::ser_auth_mode(&mut object_6, item_5)?;
25                object_6.finish();
26            }
27        }
28        array_4.finish();
29    }
30    {
31        let mut array_7 = object.key("defaultPublishAuthModes").start_array();
32        for item_8 in &input.default_publish_auth_modes {
33            {
34                #[allow(unused_mut)]
35                let mut object_9 = array_7.value().start_object();
36                crate::protocol_serde::shape_auth_mode::ser_auth_mode(&mut object_9, item_8)?;
37                object_9.finish();
38            }
39        }
40        array_7.finish();
41    }
42    {
43        let mut array_10 = object.key("defaultSubscribeAuthModes").start_array();
44        for item_11 in &input.default_subscribe_auth_modes {
45            {
46                #[allow(unused_mut)]
47                let mut object_12 = array_10.value().start_object();
48                crate::protocol_serde::shape_auth_mode::ser_auth_mode(&mut object_12, item_11)?;
49                object_12.finish();
50            }
51        }
52        array_10.finish();
53    }
54    if let Some(var_13) = &input.log_config {
55        #[allow(unused_mut)]
56        let mut object_14 = object.key("logConfig").start_object();
57        crate::protocol_serde::shape_event_log_config::ser_event_log_config(&mut object_14, var_13)?;
58        object_14.finish();
59    }
60    Ok(())
61}
62
63pub(crate) fn de_event_config<'a, I>(
64    tokens: &mut ::std::iter::Peekable<I>,
65) -> ::std::result::Result<Option<crate::types::EventConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
66where
67    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
68{
69    match tokens.next().transpose()? {
70        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
71        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
72            #[allow(unused_mut)]
73            let mut builder = crate::types::builders::EventConfigBuilder::default();
74            loop {
75                match tokens.next().transpose()? {
76                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
77                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
78                        "authProviders" => {
79                            builder = builder.set_auth_providers(crate::protocol_serde::shape_auth_providers::de_auth_providers(tokens)?);
80                        }
81                        "connectionAuthModes" => {
82                            builder = builder.set_connection_auth_modes(crate::protocol_serde::shape_auth_modes::de_auth_modes(tokens)?);
83                        }
84                        "defaultPublishAuthModes" => {
85                            builder = builder.set_default_publish_auth_modes(crate::protocol_serde::shape_auth_modes::de_auth_modes(tokens)?);
86                        }
87                        "defaultSubscribeAuthModes" => {
88                            builder = builder.set_default_subscribe_auth_modes(crate::protocol_serde::shape_auth_modes::de_auth_modes(tokens)?);
89                        }
90                        "logConfig" => {
91                            builder = builder.set_log_config(crate::protocol_serde::shape_event_log_config::de_event_log_config(tokens)?);
92                        }
93                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
94                    },
95                    other => {
96                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
97                            "expected object key or end object, found: {:?}",
98                            other
99                        )))
100                    }
101                }
102            }
103            Ok(Some(crate::serde_util::event_config_correct_errors(builder).build().map_err(|err| {
104                ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
105            })?))
106        }
107        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
108            "expected start object or null",
109        )),
110    }
111}