aws_sdk_backup/protocol_serde/
shape_recovery_point_by_resource.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_recovery_point_by_resource<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::RecoveryPointByResource>, ::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::RecoveryPointByResourceBuilder::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                        "RecoveryPointArn" => {
18                            builder = builder.set_recovery_point_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                        "CreationDate" => {
25                            builder = builder.set_creation_date(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
26                                tokens.next(),
27                                ::aws_smithy_types::date_time::Format::EpochSeconds,
28                            )?);
29                        }
30                        "Status" => {
31                            builder = builder.set_status(
32                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
33                                    .map(|s| s.to_unescaped().map(|u| crate::types::RecoveryPointStatus::from(u.as_ref())))
34                                    .transpose()?,
35                            );
36                        }
37                        "StatusMessage" => {
38                            builder = builder.set_status_message(
39                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
40                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
41                                    .transpose()?,
42                            );
43                        }
44                        "EncryptionKeyArn" => {
45                            builder = builder.set_encryption_key_arn(
46                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
47                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
48                                    .transpose()?,
49                            );
50                        }
51                        "BackupSizeBytes" => {
52                            builder = builder.set_backup_size_bytes(
53                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
54                                    .map(i64::try_from)
55                                    .transpose()?,
56                            );
57                        }
58                        "BackupVaultName" => {
59                            builder = builder.set_backup_vault_name(
60                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
61                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
62                                    .transpose()?,
63                            );
64                        }
65                        "IsParent" => {
66                            builder = builder.set_is_parent(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
67                        }
68                        "ParentRecoveryPointArn" => {
69                            builder = builder.set_parent_recovery_point_arn(
70                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
71                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
72                                    .transpose()?,
73                            );
74                        }
75                        "ResourceName" => {
76                            builder = builder.set_resource_name(
77                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
78                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
79                                    .transpose()?,
80                            );
81                        }
82                        "VaultType" => {
83                            builder = builder.set_vault_type(
84                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
85                                    .map(|s| s.to_unescaped().map(|u| crate::types::VaultType::from(u.as_ref())))
86                                    .transpose()?,
87                            );
88                        }
89                        "IndexStatus" => {
90                            builder = builder.set_index_status(
91                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
92                                    .map(|s| s.to_unescaped().map(|u| crate::types::IndexStatus::from(u.as_ref())))
93                                    .transpose()?,
94                            );
95                        }
96                        "IndexStatusMessage" => {
97                            builder = builder.set_index_status_message(
98                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
99                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
100                                    .transpose()?,
101                            );
102                        }
103                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
104                    },
105                    other => {
106                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
107                            "expected object key or end object, found: {:?}",
108                            other
109                        )))
110                    }
111                }
112            }
113            Ok(Some(builder.build()))
114        }
115        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
116            "expected start object or null",
117        )),
118    }
119}