1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /* JsonParserGenerator.kt:551 */
|
2 3 | pub(crate) fn de_my_union<'a, I>(
|
3 4 | tokens: &mut ::std::iter::Peekable<I>,
|
4 5 | ) -> ::std::result::Result<Option<crate::types::MyUnion>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
5 6 | where
|
6 7 | I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
|
7 8 | {
|
9 + | /* JsonParserGenerator.kt:565 */
|
8 10 | let mut variant = None;
|
11 + | /* JsonParserGenerator.kt:567 */
|
9 12 | match tokens.next().transpose()? {
|
10 - | Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
|
11 - | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
|
13 + | /* JsonParserGenerator.kt:568 */ Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
|
14 + | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
|
15 + | /* JsonParserGenerator.kt:684 */
|
16 + | loop {
|
17 + | /* JsonParserGenerator.kt:685 */
|
12 18 | match tokens.next().transpose()? {
|
13 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
19 + | /* JsonParserGenerator.kt:686 */ Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
14 20 | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
21 + | /* JsonParserGenerator.kt:576 */
|
15 22 | if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
|
16 23 | tokens.peek()
|
17 24 | {
|
18 25 | let _ = tokens.next().expect("peek returned a token")?;
|
19 26 | continue;
|
20 27 | }
|
28 + | /* JsonParserGenerator.kt:585 */
|
21 29 | let key = key.to_unescaped()?;
|
22 30 | if key == "__type" {
|
23 31 | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
24 32 | continue;
|
25 33 | }
|
26 34 | if variant.is_some() {
|
27 35 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
28 36 | "encountered mixed variants in union",
|
29 37 | ));
|
30 38 | }
|
39 + | /* JsonParserGenerator.kt:598 */
|
31 40 | variant = match key.as_ref() {
|
32 - | "stringValue" => Some(crate::types::MyUnion::StringValue(
|
41 + | /* JsonParserGenerator.kt:601 */
|
42 + | "stringValue" => {
|
43 + | /* JsonParserGenerator.kt:611 */
|
44 + | Some(crate::types::MyUnion::StringValue(
|
45 + | /* JsonParserGenerator.kt:354 */
|
33 46 | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
34 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
47 + | .map(|s|
|
48 + | /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
|
49 + | /* JsonParserGenerator.kt:348 */u.into_owned()
|
50 + | /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
|
35 51 | .transpose()?
|
52 + | /* JsonParserGenerator.kt:670 */
|
36 53 | .ok_or_else(|| {
|
37 54 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValue' cannot be null")
|
38 - | })?,
|
39 - | )),
|
40 - | "booleanValue" => Some(crate::types::MyUnion::BooleanValue(
|
41 - | ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?.ok_or_else(|| {
|
55 + | })?, /* JsonParserGenerator.kt:611 */
|
56 + | ))
|
57 + | /* JsonParserGenerator.kt:601 */
|
58 + | }
|
59 + | /* JsonParserGenerator.kt:601 */
|
60 + | "booleanValue" => {
|
61 + | /* JsonParserGenerator.kt:611 */
|
62 + | Some(crate::types::MyUnion::BooleanValue(
|
63 + | /* JsonParserGenerator.kt:298 */
|
64 + | ::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
|
65 + | /* JsonParserGenerator.kt:670 */
|
66 + | .ok_or_else(|| {
|
42 67 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValue' cannot be null")
|
43 - | })?,
|
44 - | )),
|
45 - | "numberValue" => Some(crate::types::MyUnion::NumberValue(
|
68 + | })?, /* JsonParserGenerator.kt:611 */
|
69 + | ))
|
70 + | /* JsonParserGenerator.kt:601 */
|
71 + | }
|
72 + | /* JsonParserGenerator.kt:601 */
|
73 + | "numberValue" => {
|
74 + | /* JsonParserGenerator.kt:611 */
|
75 + | Some(crate::types::MyUnion::NumberValue(
|
76 + | /* JsonParserGenerator.kt:365 */
|
46 77 | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
47 78 | .map(i32::try_from)
|
48 79 | .transpose()?
|
80 + | /* JsonParserGenerator.kt:670 */
|
49 81 | .ok_or_else(|| {
|
50 82 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'numberValue' cannot be null")
|
51 - | })?,
|
52 - | )),
|
53 - | "blobValue" => Some(crate::types::MyUnion::BlobValue(
|
54 - | ::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?.ok_or_else(|| {
|
83 + | })?, /* JsonParserGenerator.kt:611 */
|
84 + | ))
|
85 + | /* JsonParserGenerator.kt:601 */
|
86 + | }
|
87 + | /* JsonParserGenerator.kt:601 */
|
88 + | "blobValue" => {
|
89 + | /* JsonParserGenerator.kt:611 */
|
90 + | Some(crate::types::MyUnion::BlobValue(
|
91 + | /* JsonParserGenerator.kt:326 */
|
92 + | ::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
|
93 + | /* JsonParserGenerator.kt:670 */
|
94 + | .ok_or_else(|| {
|
55 95 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobValue' cannot be null")
|
56 - | })?,
|
57 - | )),
|
58 - | "timestampValue" => Some(crate::types::MyUnion::TimestampValue(
|
96 + | })?, /* JsonParserGenerator.kt:611 */
|
97 + | ))
|
98 + | /* JsonParserGenerator.kt:601 */
|
99 + | }
|
100 + | /* JsonParserGenerator.kt:601 */
|
101 + | "timestampValue" => {
|
102 + | /* JsonParserGenerator.kt:611 */
|
103 + | Some(crate::types::MyUnion::TimestampValue(
|
104 + | /* JsonParserGenerator.kt:384 */
|
59 105 | ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
|
60 106 | tokens.next(),
|
61 107 | ::aws_smithy_types::date_time::Format::EpochSeconds,
|
62 108 | )?
|
109 + | /* JsonParserGenerator.kt:670 */
|
63 110 | .ok_or_else(|| {
|
64 111 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampValue' cannot be null")
|
65 - | })?,
|
66 - | )),
|
67 - | "enumValue" => Some(crate::types::MyUnion::EnumValue(
|
112 + | })?, /* JsonParserGenerator.kt:611 */
|
113 + | ))
|
114 + | /* JsonParserGenerator.kt:601 */
|
115 + | }
|
116 + | /* JsonParserGenerator.kt:601 */
|
117 + | "enumValue" => {
|
118 + | /* JsonParserGenerator.kt:611 */
|
119 + | Some(crate::types::MyUnion::EnumValue(
|
120 + | /* JsonParserGenerator.kt:354 */
|
68 121 | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
69 - | .map(|s| s.to_unescaped().map(|u| crate::types::FooEnum::from(u.as_ref())))
|
122 + | .map(|s|
|
123 + | /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
|
124 + | /* JsonParserGenerator.kt:345 */crate::types::FooEnum::from(u.as_ref())
|
125 + | /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
|
70 126 | .transpose()?
|
127 + | /* JsonParserGenerator.kt:670 */
|
71 128 | .ok_or_else(|| {
|
72 129 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumValue' cannot be null")
|
73 - | })?,
|
74 - | )),
|
75 - | "listValue" => Some(crate::types::MyUnion::ListValue(
|
76 - | crate::protocol_serde::shape_string_list::de_string_list(tokens)?.ok_or_else(|| {
|
130 + | })?, /* JsonParserGenerator.kt:611 */
|
131 + | ))
|
132 + | /* JsonParserGenerator.kt:601 */
|
133 + | }
|
134 + | /* JsonParserGenerator.kt:601 */
|
135 + | "listValue" => {
|
136 + | /* JsonParserGenerator.kt:611 */
|
137 + | Some(crate::types::MyUnion::ListValue(
|
138 + | /* JsonParserGenerator.kt:451 */
|
139 + | crate::protocol_serde::shape_string_list::de_string_list(tokens)?
|
140 + | /* JsonParserGenerator.kt:670 */
|
141 + | .ok_or_else(|| {
|
77 142 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listValue' cannot be null")
|
78 - | })?,
|
79 - | )),
|
80 - | "mapValue" => Some(crate::types::MyUnion::MapValue(
|
81 - | crate::protocol_serde::shape_string_map::de_string_map(tokens)?.ok_or_else(|| {
|
143 + | })?, /* JsonParserGenerator.kt:611 */
|
144 + | ))
|
145 + | /* JsonParserGenerator.kt:601 */
|
146 + | }
|
147 + | /* JsonParserGenerator.kt:601 */
|
148 + | "mapValue" => {
|
149 + | /* JsonParserGenerator.kt:611 */
|
150 + | Some(crate::types::MyUnion::MapValue(
|
151 + | /* JsonParserGenerator.kt:509 */
|
152 + | crate::protocol_serde::shape_string_map::de_string_map(tokens)?
|
153 + | /* JsonParserGenerator.kt:670 */
|
154 + | .ok_or_else(|| {
|
82 155 | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapValue' cannot be null")
|
83 - | })?,
|
84 - | )),
|
85 - | "structureValue" => Some(crate::types::MyUnion::StructureValue(
|
86 - | crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?.ok_or_else(|| {
|
87 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'structureValue' cannot be null")
|
88 - | })?,
|
89 - | )),
|
90 - | "renamedStructureValue" => Some(crate::types::MyUnion::RenamedStructureValue(
|
91 - | crate::protocol_serde::shape_renamed_greeting::de_renamed_greeting(tokens)?.ok_or_else(|| {
|
92 - | ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'renamedStructureValue' cannot be null")
|
93 - | })?,
|
94 - | )),
|
156 + | })?, /* JsonParserGenerator.kt:611 */
|
157 + | ))
|
158 + | /* JsonParserGenerator.kt:601 */
|
159 + | }
|
160 + | /* JsonParserGenerator.kt:601 */
|
161 + | "structureValue" => {
|
162 + | /* JsonParserGenerator.kt:611 */
|
163 + | Some(crate::types::MyUnion::StructureValue(
|
164 + | /* JsonParserGenerator.kt:544 */
|
165 + | crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
|
166 + | /* JsonParserGenerator.kt:670 */
|
167 + | .ok_or_else(|| {
|
168 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
169 + | "value for 'structureValue' cannot be null",
|
170 + | )
|
171 + | })?, /* JsonParserGenerator.kt:611 */
|
172 + | ))
|
173 + | /* JsonParserGenerator.kt:601 */
|
174 + | }
|
175 + | /* JsonParserGenerator.kt:601 */
|
176 + | "renamedStructureValue" => {
|
177 + | /* JsonParserGenerator.kt:611 */
|
178 + | Some(crate::types::MyUnion::RenamedStructureValue(
|
179 + | /* JsonParserGenerator.kt:544 */
|
180 + | crate::protocol_serde::shape_renamed_greeting::de_renamed_greeting(tokens)?
|
181 + | /* JsonParserGenerator.kt:670 */
|
182 + | .ok_or_else(|| {
|
183 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
184 + | "value for 'renamedStructureValue' cannot be null",
|
185 + | )
|
186 + | })?, /* JsonParserGenerator.kt:611 */
|
187 + | ))
|
188 + | /* JsonParserGenerator.kt:601 */
|
189 + | }
|
190 + | /* JsonParserGenerator.kt:621 */
|
95 191 | _ => {
|
96 192 | ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
|
97 193 | Some(crate::types::MyUnion::Unknown)
|
98 - | }
|
194 + | } /* JsonParserGenerator.kt:598 */
|
99 195 | };
|
196 + | /* JsonParserGenerator.kt:686 */
|
100 197 | }
|
198 + | /* JsonParserGenerator.kt:695 */
|
101 199 | other => {
|
102 200 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
103 201 | "expected object key or end object, found: {:?}",
|
104 202 | other
|
105 203 | )))
|
204 + | } /* JsonParserGenerator.kt:685 */
|
205 + | }
|
206 + | /* JsonParserGenerator.kt:684 */
|
106 207 | }
|
208 + | /* JsonParserGenerator.kt:568 */
|
107 209 | }
|
108 - | },
|
210 + | /* JsonParserGenerator.kt:642 */
|
109 211 | _ => {
|
110 212 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
111 213 | "expected start object or null",
|
112 214 | ))
|
215 + | } /* JsonParserGenerator.kt:567 */
|
113 216 | }
|
114 - | }
|
217 + | /* JsonParserGenerator.kt:649 */
|
115 218 | if variant.is_none() {
|
116 219 | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
117 220 | "Union did not contain a valid variant.",
|
118 221 | ));
|
119 222 | }
|
223 + | /* JsonParserGenerator.kt:657 */
|
120 224 | Ok(variant)
|
225 + | /* JsonParserGenerator.kt:551 */
|
121 226 | }
|
122 227 |
|
228 + | /* JsonSerializerGenerator.kt:547 */
|
123 229 | pub fn ser_my_union(
|
124 230 | object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
|
125 231 | input: &crate::types::MyUnion,
|
126 232 | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
|
233 + | /* JsonSerializerGenerator.kt:556 */
|
127 234 | match input {
|
235 + | /* JsonSerializerGenerator.kt:564 */
|
128 236 | crate::types::MyUnion::StringValue(inner) => {
|
237 + | /* SerializerUtil.kt:42 */
|
238 + | {
|
239 + | /* JsonSerializerGenerator.kt:423 */
|
129 240 | object_2.key("stringValue").string(inner.as_str());
|
241 + | /* SerializerUtil.kt:42 */
|
242 + | }
|
243 + | /* JsonSerializerGenerator.kt:564 */
|
130 244 | }
|
245 + | /* JsonSerializerGenerator.kt:564 */
|
131 246 | crate::types::MyUnion::BooleanValue(inner) => {
|
247 + | /* SerializerUtil.kt:42 */
|
248 + | {
|
249 + | /* JsonSerializerGenerator.kt:424 */
|
132 250 | object_2.key("booleanValue").boolean(*inner);
|
251 + | /* SerializerUtil.kt:42 */
|
252 + | }
|
253 + | /* JsonSerializerGenerator.kt:564 */
|
133 254 | }
|
255 + | /* JsonSerializerGenerator.kt:564 */
|
134 256 | crate::types::MyUnion::NumberValue(inner) => {
|
257 + | /* SerializerUtil.kt:42 */
|
258 + | {
|
259 + | /* JsonSerializerGenerator.kt:432 */
|
135 260 | object_2.key("numberValue").number(
|
136 261 | #[allow(clippy::useless_conversion)]
|
137 262 | ::aws_smithy_types::Number::NegInt((*inner).into()),
|
138 263 | );
|
264 + | /* SerializerUtil.kt:42 */
|
139 265 | }
|
266 + | /* JsonSerializerGenerator.kt:564 */
|
267 + | }
|
268 + | /* JsonSerializerGenerator.kt:564 */
|
140 269 | crate::types::MyUnion::BlobValue(inner) => {
|
270 + | /* SerializerUtil.kt:42 */
|
271 + | {
|
272 + | /* JsonSerializerGenerator.kt:439 */
|
141 273 | object_2.key("blobValue").string_unchecked(&::aws_smithy_types::base64::encode(inner));
|
274 + | /* SerializerUtil.kt:42 */
|
275 + | }
|
276 + | /* JsonSerializerGenerator.kt:564 */
|
142 277 | }
|
278 + | /* JsonSerializerGenerator.kt:564 */
|
143 279 | crate::types::MyUnion::TimestampValue(inner) => {
|
280 + | /* SerializerUtil.kt:42 */
|
281 + | {
|
282 + | /* JsonSerializerGenerator.kt:448 */
|
144 283 | object_2
|
145 284 | .key("timestampValue")
|
146 285 | .date_time(inner, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
|
286 + | /* SerializerUtil.kt:42 */
|
287 + | }
|
288 + | /* JsonSerializerGenerator.kt:564 */
|
147 289 | }
|
290 + | /* JsonSerializerGenerator.kt:564 */
|
148 291 | crate::types::MyUnion::EnumValue(inner) => {
|
292 + | /* SerializerUtil.kt:42 */
|
293 + | {
|
294 + | /* JsonSerializerGenerator.kt:423 */
|
149 295 | object_2.key("enumValue").string(inner.as_str());
|
296 + | /* SerializerUtil.kt:42 */
|
150 297 | }
|
298 + | /* JsonSerializerGenerator.kt:564 */
|
299 + | }
|
300 + | /* JsonSerializerGenerator.kt:564 */
|
151 301 | crate::types::MyUnion::ListValue(inner) => {
|
302 + | /* SerializerUtil.kt:42 */
|
303 + | {
|
304 + | /* JsonSerializerGenerator.kt:484 */
|
152 305 | let mut array_1 = object_2.key("listValue").start_array();
|
306 + | /* JsonSerializerGenerator.kt:524 */
|
153 307 | for item_2 in inner {
|
308 + | /* SerializerUtil.kt:42 */
|
154 309 | {
|
310 + | /* JsonSerializerGenerator.kt:423 */
|
155 311 | array_1.value().string(item_2.as_str());
|
312 + | /* SerializerUtil.kt:42 */
|
156 313 | }
|
314 + | /* JsonSerializerGenerator.kt:524 */
|
157 315 | }
|
316 + | /* JsonSerializerGenerator.kt:486 */
|
158 317 | array_1.finish();
|
318 + | /* SerializerUtil.kt:42 */
|
319 + | }
|
320 + | /* JsonSerializerGenerator.kt:564 */
|
159 321 | }
|
322 + | /* JsonSerializerGenerator.kt:564 */
|
160 323 | crate::types::MyUnion::MapValue(inner) => {
|
324 + | /* SerializerUtil.kt:42 */
|
325 + | {
|
326 + | /* JsonSerializerGenerator.kt:495 */
|
161 327 | #[allow(unused_mut)]
|
328 + | /* JsonSerializerGenerator.kt:496 */
|
162 329 | let mut object_3 = object_2.key("mapValue").start_object();
|
330 + | /* JsonSerializerGenerator.kt:537 */
|
163 331 | for (key_4, value_5) in inner {
|
332 + | /* SerializerUtil.kt:42 */
|
164 333 | {
|
334 + | /* JsonSerializerGenerator.kt:423 */
|
165 335 | object_3.key(key_4.as_str()).string(value_5.as_str());
|
336 + | /* SerializerUtil.kt:42 */
|
166 337 | }
|
338 + | /* JsonSerializerGenerator.kt:537 */
|
167 339 | }
|
340 + | /* JsonSerializerGenerator.kt:515 */
|
168 341 | object_3.finish();
|
342 + | /* SerializerUtil.kt:42 */
|
343 + | }
|
344 + | /* JsonSerializerGenerator.kt:564 */
|
169 345 | }
|
346 + | /* JsonSerializerGenerator.kt:564 */
|
170 347 | crate::types::MyUnion::StructureValue(inner) => {
|
348 + | /* SerializerUtil.kt:42 */
|
349 + | {
|
350 + | /* JsonSerializerGenerator.kt:495 */
|
171 351 | #[allow(unused_mut)]
|
352 + | /* JsonSerializerGenerator.kt:496 */
|
172 353 | let mut object_6 = object_2.key("structureValue").start_object();
|
354 + | /* JsonSerializerGenerator.kt:375 */
|
173 355 | crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(&mut object_6, inner)?;
|
356 + | /* JsonSerializerGenerator.kt:515 */
|
174 357 | object_6.finish();
|
358 + | /* SerializerUtil.kt:42 */
|
175 359 | }
|
360 + | /* JsonSerializerGenerator.kt:564 */
|
361 + | }
|
362 + | /* JsonSerializerGenerator.kt:564 */
|
176 363 | crate::types::MyUnion::RenamedStructureValue(inner) => {
|
364 + | /* SerializerUtil.kt:42 */
|
365 + | {
|
366 + | /* JsonSerializerGenerator.kt:495 */
|
177 367 | #[allow(unused_mut)]
|
368 + | /* JsonSerializerGenerator.kt:496 */
|
178 369 | let mut object_7 = object_2.key("renamedStructureValue").start_object();
|
370 + | /* JsonSerializerGenerator.kt:375 */
|
179 371 | crate::protocol_serde::shape_renamed_greeting::ser_renamed_greeting(&mut object_7, inner)?;
|
372 + | /* JsonSerializerGenerator.kt:515 */
|
180 373 | object_7.finish();
|
374 + | /* SerializerUtil.kt:42 */
|
375 + | }
|
376 + | /* JsonSerializerGenerator.kt:564 */
|
181 377 | }
|
182 - | crate::types::MyUnion::Unknown => return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("MyUnion")),
|
378 + | /* JsonSerializerGenerator.kt:569 */
|
379 + | crate::types::MyUnion::Unknown => return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("MyUnion")), /* JsonSerializerGenerator.kt:556 */
|
183 380 | }
|
381 + | /* JsonSerializerGenerator.kt:576 */
|
184 382 | Ok(())
|
383 + | /* JsonSerializerGenerator.kt:547 */
|
185 384 | }
|