aws_sdk_cloudhsmv2/protocol_serde/
shape_backup.rs1pub(crate) fn de_backup<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4 _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::Backup>, ::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::BackupBuilder::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 "BackupId" => {
19 builder = builder.set_backup_id(
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 "BackupArn" => {
26 builder = builder.set_backup_arn(
27 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
28 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
29 .transpose()?,
30 );
31 }
32 "BackupState" => {
33 builder = builder.set_backup_state(
34 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
35 .map(|s| s.to_unescaped().map(|u| crate::types::BackupState::from(u.as_ref())))
36 .transpose()?,
37 );
38 }
39 "ClusterId" => {
40 builder = builder.set_cluster_id(
41 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43 .transpose()?,
44 );
45 }
46 "CreateTimestamp" => {
47 builder = builder.set_create_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
48 tokens.next(),
49 ::aws_smithy_types::date_time::Format::EpochSeconds,
50 )?);
51 }
52 "CopyTimestamp" => {
53 builder = builder.set_copy_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
54 tokens.next(),
55 ::aws_smithy_types::date_time::Format::EpochSeconds,
56 )?);
57 }
58 "NeverExpires" => {
59 builder = builder.set_never_expires(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
60 }
61 "SourceRegion" => {
62 builder = builder.set_source_region(
63 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
64 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
65 .transpose()?,
66 );
67 }
68 "SourceBackup" => {
69 builder = builder.set_source_backup(
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 "SourceCluster" => {
76 builder = builder.set_source_cluster(
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 "DeleteTimestamp" => {
83 builder = builder.set_delete_timestamp(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
84 tokens.next(),
85 ::aws_smithy_types::date_time::Format::EpochSeconds,
86 )?);
87 }
88 "TagList" => {
89 builder = builder.set_tag_list(crate::protocol_serde::shape_tag_list::de_tag_list(tokens, _value)?);
90 }
91 "HsmType" => {
92 builder = builder.set_hsm_type(
93 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
94 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
95 .transpose()?,
96 );
97 }
98 "Mode" => {
99 builder = builder.set_mode(
100 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
101 .map(|s| s.to_unescaped().map(|u| crate::types::ClusterMode::from(u.as_ref())))
102 .transpose()?,
103 );
104 }
105 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
106 },
107 other => {
108 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
109 "expected object key or end object, found: {other:?}"
110 )))
111 }
112 }
113 }
114 Ok(Some(crate::serde_util::backup_correct_errors(builder).build().map_err(|err| {
115 ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
116 })?))
117 }
118 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
119 "expected start object or null",
120 )),
121 }
122}