1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | pub fn ser_attribute_value(
|
3 - | object_6: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
|
4 - | input: &crate::types::AttributeValue,
|
5 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
|
6 - | match input {
|
7 - | crate::types::AttributeValue::S(inner) => {
|
8 - | object_6.key("S").string(inner.as_str());
|
9 - | }
|
10 - | crate::types::AttributeValue::N(inner) => {
|
11 - | object_6.key("N").string(inner.as_str());
|
12 - | }
|
13 - | crate::types::AttributeValue::B(inner) => {
|
14 - | object_6.key("B").string_unchecked(&::aws_smithy_types::base64::encode(inner));
|
15 - | }
|
16 - | crate::types::AttributeValue::Ss(inner) => {
|
17 - | let mut array_1 = object_6.key("SS").start_array();
|
18 - | for item_2 in inner {
|
19 - | {
|
20 - | array_1.value().string(item_2.as_str());
|
21 - | }
|
22 - | }
|
23 - | array_1.finish();
|
24 - | }
|
25 - | crate::types::AttributeValue::Ns(inner) => {
|
26 - | let mut array_3 = object_6.key("NS").start_array();
|
27 - | for item_4 in inner {
|
28 - | {
|
29 - | array_3.value().string(item_4.as_str());
|
30 - | }
|
31 - | }
|
32 - | array_3.finish();
|
33 - | }
|
34 - | crate::types::AttributeValue::Bs(inner) => {
|
35 - | let mut array_5 = object_6.key("BS").start_array();
|
36 - | for item_6 in inner {
|
37 - | {
|
38 - | array_5.value().string_unchecked(&::aws_smithy_types::base64::encode(item_6));
|
39 - | }
|
40 - | }
|
41 - | array_5.finish();
|
42 - | }
|
43 - | crate::types::AttributeValue::M(inner) => {
|
44 - | #[allow(unused_mut)]
|
45 - | let mut object_7 = object_6.key("M").start_object();
|
46 - | for (key_8, value_9) in inner {
|
47 - | {
|
48 - | #[allow(unused_mut)]
|
49 - | let mut object_10 = object_7.key(key_8.as_str()).start_object();
|
50 - | crate::protocol_serde::shape_attribute_value::ser_attribute_value(&mut object_10, value_9)?;
|
51 - | object_10.finish();
|
52 - | }
|
53 - | }
|
54 - | object_7.finish();
|
55 - | }
|
56 - | crate::types::AttributeValue::L(inner) => {
|
57 - | let mut array_11 = object_6.key("L").start_array();
|
58 - | for item_12 in inner {
|
59 - | {
|
60 - | #[allow(unused_mut)]
|
61 - | let mut object_13 = array_11.value().start_object();
|
62 - | crate::protocol_serde::shape_attribute_value::ser_attribute_value(&mut object_13, item_12)?;
|
63 - | object_13.finish();
|
64 - | }
|
65 - | }
|
66 - | array_11.finish();
|
67 - | }
|
68 - | crate::types::AttributeValue::Null(inner) => {
|
69 - | object_6.key("NULL").boolean(*inner);
|
70 - | }
|
71 - | crate::types::AttributeValue::Bool(inner) => {
|
72 - | object_6.key("BOOL").boolean(*inner);
|
73 - | }
|
74 - | crate::types::AttributeValue::Unknown => {
|
75 - | return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
|
76 - | "AttributeValue",
|
77 - | ))
|
78 - | }
|
79 - | }
|
80 - | Ok(())
|
81 - | }
|
82 - |
|
83 - | pub(crate) fn de_attribute_value<'a, I>(
|
84 - | tokens: &mut ::std::iter::Peekable<I>,
|
85 - | _value: &'a [u8],
|
86 - | ) -> ::std::result::Result<Option<crate::types::AttributeValue>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
87 - | where
|
88 - | I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
|
89 - | {
|
90 - | let mut variant = None;
|
91 - | match tokens.next().transpose()? {
|
92 - | Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
|
93 - | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
|
94 - | match tokens.next().transpose()? {
|
95 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
96 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
97 - | if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
|
98 - | tokens.peek()
|
99 - | {
|
100 - | let _ = tokens.next().expect("peek returned a token")?;
|
101 - | continue;
|
102 - | }
|
103 - | let key = key.to_unescaped()?;
|
104 - | if key == "__type" {
|
105 - | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
106 - | continue;
|
107 - | }
|
108 - | if variant.is_some() {
|
109 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
110 - | "encountered mixed variants in union",
|
111 - | ));
|
112 - | }
|
113 - | variant = match key.as_ref() {
|
114 - | "S" => Some(crate::types::AttributeValue::S(
|
115 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
116 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
117 - | .transpose()?
|
118 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'S' cannot be null"))?,
|
119 - | )),
|
120 - | "N" => Some(crate::types::AttributeValue::N(
|
121 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
122 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
123 - | .transpose()?
|
124 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'N' cannot be null"))?,
|
125 - | )),
|
126 - | "B" => Some(crate::types::AttributeValue::B(
|
127 - | ::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
|
128 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'B' cannot be null"))?,
|
129 - | )),
|
130 - | "SS" => Some(crate::types::AttributeValue::Ss(
|
131 - | crate::protocol_serde::shape_string_set_attribute_value::de_string_set_attribute_value(tokens, _value)?
|
132 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'SS' cannot be null"))?,
|
133 - | )),
|
134 - | "NS" => Some(crate::types::AttributeValue::Ns(
|
135 - | crate::protocol_serde::shape_number_set_attribute_value::de_number_set_attribute_value(tokens, _value)?
|
136 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'NS' cannot be null"))?,
|
137 - | )),
|
138 - | "BS" => Some(crate::types::AttributeValue::Bs(
|
139 - | crate::protocol_serde::shape_binary_set_attribute_value::de_binary_set_attribute_value(tokens, _value)?
|
140 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'BS' cannot be null"))?,
|
141 - | )),
|
142 - | "M" => Some(crate::types::AttributeValue::M(
|
143 - | crate::protocol_serde::shape_map_attribute_value::de_map_attribute_value(tokens, _value)?
|
144 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'M' cannot be null"))?,
|
145 - | )),
|
146 - | "L" => Some(crate::types::AttributeValue::L(
|
147 - | crate::protocol_serde::shape_list_attribute_value::de_list_attribute_value(tokens, _value)?
|
148 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'L' cannot be null"))?,
|
149 - | )),
|
150 - | "NULL" => Some(crate::types::AttributeValue::Null(
|
151 - | ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
|
152 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'NULL' cannot be null"))?,
|
153 - | )),
|
154 - | "BOOL" => Some(crate::types::AttributeValue::Bool(
|
155 - | ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
|
156 - | .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'BOOL' cannot be null"))?,
|
157 - | )),
|
158 - | _ => {
|
159 - | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
160 - | Some(crate::types::AttributeValue::Unknown)
|
161 - | }
|
162 - | };
|
163 - | }
|
164 - | other => {
|
165 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
166 - | "expected object key or end object, found: {other:?}"
|
167 - | )))
|
168 - | }
|
169 - | }
|
170 - | },
|
171 - | _ => {
|
172 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
173 - | "expected start object or null",
|
174 - | ))
|
175 - | }
|
176 - | }
|
177 - | if variant.is_none() {
|
178 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
179 - | "Union did not contain a valid variant.",
|
180 - | ));
|
181 - | }
|
182 - | Ok(variant)
|
183 - | }
|