Skip to main content

aws_sdk_sesv2/protocol_serde/
shape_event_destination.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_event_destination<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4    _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::EventDestination>, ::aws_smithy_json::deserialize::error::DeserializeError>
6where
7    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
8{
9    match tokens.next().transpose()? {
10        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
11        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
12            #[allow(unused_mut)]
13            let mut builder = crate::types::builders::EventDestinationBuilder::default();
14            loop {
15                match tokens.next().transpose()? {
16                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
17                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
18                        "Name" => {
19                            builder = builder.set_name(
20                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
21                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
22                                    .transpose()?,
23                            );
24                        }
25                        "Enabled" => {
26                            builder = builder.set_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
27                        }
28                        "MatchingEventTypes" => {
29                            builder = builder.set_matching_event_types(crate::protocol_serde::shape_event_types::de_event_types(tokens, _value)?);
30                        }
31                        "KinesisFirehoseDestination" => {
32                            builder = builder.set_kinesis_firehose_destination(
33                                crate::protocol_serde::shape_kinesis_firehose_destination::de_kinesis_firehose_destination(tokens, _value)?,
34                            );
35                        }
36                        "CloudWatchDestination" => {
37                            builder = builder.set_cloud_watch_destination(
38                                crate::protocol_serde::shape_cloud_watch_destination::de_cloud_watch_destination(tokens, _value)?,
39                            );
40                        }
41                        "SnsDestination" => {
42                            builder = builder.set_sns_destination(crate::protocol_serde::shape_sns_destination::de_sns_destination(tokens, _value)?);
43                        }
44                        "EventBridgeDestination" => {
45                            builder = builder.set_event_bridge_destination(
46                                crate::protocol_serde::shape_event_bridge_destination::de_event_bridge_destination(tokens, _value)?,
47                            );
48                        }
49                        "PinpointDestination" => {
50                            builder = builder.set_pinpoint_destination(crate::protocol_serde::shape_pinpoint_destination::de_pinpoint_destination(
51                                tokens, _value,
52                            )?);
53                        }
54                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
55                    },
56                    other => {
57                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
58                            "expected object key or end object, found: {other:?}"
59                        )))
60                    }
61                }
62            }
63            Ok(Some(crate::serde_util::event_destination_correct_errors(builder).build().map_err(
64                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
65            )?))
66        }
67        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
68            "expected start object or null",
69        )),
70    }
71}