aws_sdk_connect/protocol_serde/
shape_reference_summary.rs1pub(crate) fn de_reference_summary<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::ReferenceSummary>, ::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 let mut variant = None;
9 match tokens.next().transpose()? {
10 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
11 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
12 match tokens.next().transpose()? {
13 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
14 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
15 if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
16 tokens.peek()
17 {
18 let _ = tokens.next().expect("peek returned a token")?;
19 continue;
20 }
21 let key = key.to_unescaped()?;
22 if key == "__type" {
23 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
24 continue;
25 }
26 if variant.is_some() {
27 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
28 "encountered mixed variants in union",
29 ));
30 }
31 variant = match key.as_ref() {
32 "Url" => Some(crate::types::ReferenceSummary::Url(
33 crate::protocol_serde::shape_url_reference::de_url_reference(tokens)?
34 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Url' cannot be null"))?,
35 )),
36 "Attachment" => Some(crate::types::ReferenceSummary::Attachment(
37 crate::protocol_serde::shape_attachment_reference::de_attachment_reference(tokens)?.ok_or_else(|| {
38 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Attachment' cannot be null")
39 })?,
40 )),
41 "EmailMessage" => Some(crate::types::ReferenceSummary::EmailMessage(
42 crate::protocol_serde::shape_email_message_reference::de_email_message_reference(tokens)?.ok_or_else(|| {
43 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'EmailMessage' cannot be null")
44 })?,
45 )),
46 "String" => Some(crate::types::ReferenceSummary::String(
47 crate::protocol_serde::shape_string_reference::de_string_reference(tokens)?.ok_or_else(|| {
48 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'String' cannot be null")
49 })?,
50 )),
51 "Number" => Some(crate::types::ReferenceSummary::Number(
52 crate::protocol_serde::shape_number_reference::de_number_reference(tokens)?.ok_or_else(|| {
53 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Number' cannot be null")
54 })?,
55 )),
56 "Date" => Some(crate::types::ReferenceSummary::Date(
57 crate::protocol_serde::shape_date_reference::de_date_reference(tokens)?
58 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Date' cannot be null"))?,
59 )),
60 "Email" => Some(crate::types::ReferenceSummary::Email(
61 crate::protocol_serde::shape_email_reference::de_email_reference(tokens)?
62 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Email' cannot be null"))?,
63 )),
64 _ => {
65 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
66 Some(crate::types::ReferenceSummary::Unknown)
67 }
68 };
69 }
70 other => {
71 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
72 "expected object key or end object, found: {:?}",
73 other
74 )))
75 }
76 }
77 },
78 _ => {
79 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
80 "expected start object or null",
81 ))
82 }
83 }
84 if variant.is_none() {
85 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
86 "Union did not contain a valid variant.",
87 ));
88 }
89 Ok(variant)
90}