aws_sdk_pinpointsmsvoicev2/protocol_serde/
shape_sender_id_information.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_sender_id_information<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::SenderIdInformation>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::SenderIdInformationBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "SenderIdArn" => {
18                            builder = builder.set_sender_id_arn(
19                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
20                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
21                                    .transpose()?,
22                            );
23                        }
24                        "SenderId" => {
25                            builder = builder.set_sender_id(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
28                                    .transpose()?,
29                            );
30                        }
31                        "IsoCountryCode" => {
32                            builder = builder.set_iso_country_code(
33                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
34                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
35                                    .transpose()?,
36                            );
37                        }
38                        "MessageTypes" => {
39                            builder = builder.set_message_types(crate::protocol_serde::shape_message_type_list::de_message_type_list(tokens)?);
40                        }
41                        "MonthlyLeasingPrice" => {
42                            builder = builder.set_monthly_leasing_price(
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                        "DeletionProtectionEnabled" => {
49                            builder =
50                                builder.set_deletion_protection_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
51                        }
52                        "Registered" => {
53                            builder = builder.set_registered(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
54                        }
55                        "RegistrationId" => {
56                            builder = builder.set_registration_id(
57                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
58                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
59                                    .transpose()?,
60                            );
61                        }
62                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
63                    },
64                    other => {
65                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
66                            "expected object key or end object, found: {:?}",
67                            other
68                        )))
69                    }
70                }
71            }
72            Ok(Some(crate::serde_util::sender_id_information_correct_errors(builder).build().map_err(
73                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
74            )?))
75        }
76        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
77            "expected start object or null",
78        )),
79    }
80}