aws_sdk_connect/protocol_serde/
shape_realtime_contact_analysis_segment.rs1pub(crate) fn de_realtime_contact_analysis_segment<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::RealtimeContactAnalysisSegment>, ::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 "Transcript" => {
33 Some(crate::types::RealtimeContactAnalysisSegment::Transcript(
34 crate::protocol_serde::shape_real_time_contact_analysis_segment_transcript::de_real_time_contact_analysis_segment_transcript(tokens)?
35 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Transcript' cannot be null"))?
36 ))
37 }
38 "Categories" => {
39 Some(crate::types::RealtimeContactAnalysisSegment::Categories(
40 crate::protocol_serde::shape_real_time_contact_analysis_segment_categories::de_real_time_contact_analysis_segment_categories(tokens)?
41 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Categories' cannot be null"))?
42 ))
43 }
44 "Issues" => {
45 Some(crate::types::RealtimeContactAnalysisSegment::Issues(
46 crate::protocol_serde::shape_real_time_contact_analysis_segment_issues::de_real_time_contact_analysis_segment_issues(tokens)?
47 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Issues' cannot be null"))?
48 ))
49 }
50 "Event" => {
51 Some(crate::types::RealtimeContactAnalysisSegment::Event(
52 crate::protocol_serde::shape_real_time_contact_analysis_segment_event::de_real_time_contact_analysis_segment_event(tokens)?
53 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Event' cannot be null"))?
54 ))
55 }
56 "Attachments" => {
57 Some(crate::types::RealtimeContactAnalysisSegment::Attachments(
58 crate::protocol_serde::shape_real_time_contact_analysis_segment_attachments::de_real_time_contact_analysis_segment_attachments(tokens)?
59 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Attachments' cannot be null"))?
60 ))
61 }
62 "PostContactSummary" => {
63 Some(crate::types::RealtimeContactAnalysisSegment::PostContactSummary(
64 crate::protocol_serde::shape_real_time_contact_analysis_segment_post_contact_summary::de_real_time_contact_analysis_segment_post_contact_summary(tokens)?
65 .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'PostContactSummary' cannot be null"))?
66 ))
67 }
68 _ => {
69 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
70 Some(crate::types::RealtimeContactAnalysisSegment::Unknown)
71 }
72 };
73 }
74 other => {
75 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
76 "expected object key or end object, found: {:?}",
77 other
78 )))
79 }
80 }
81 },
82 _ => {
83 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
84 "expected start object or null",
85 ))
86 }
87 }
88 if variant.is_none() {
89 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
90 "Union did not contain a valid variant.",
91 ));
92 }
93 Ok(variant)
94}