aws_sdk_connect/protocol_serde/
shape_real_time_contact_analysis_transcript_item_with_content.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_real_time_contact_analysis_transcript_item_with_content<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<
5    Option<crate::types::RealTimeContactAnalysisTranscriptItemWithContent>,
6    ::aws_smithy_json::deserialize::error::DeserializeError,
7>
8where
9    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
10{
11    match tokens.next().transpose()? {
12        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
13        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
14            #[allow(unused_mut)]
15            let mut builder = crate::types::builders::RealTimeContactAnalysisTranscriptItemWithContentBuilder::default();
16            loop {
17                match tokens.next().transpose()? {
18                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
19                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
20                        "Content" => {
21                            builder = builder.set_content(
22                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
23                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
24                                    .transpose()?,
25                            );
26                        }
27                        "Id" => {
28                            builder = builder.set_id(
29                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
30                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
31                                    .transpose()?,
32                            );
33                        }
34                        "CharacterOffsets" => {
35                            builder = builder.set_character_offsets(
36                                    crate::protocol_serde::shape_real_time_contact_analysis_character_interval::de_real_time_contact_analysis_character_interval(tokens)?
37                                );
38                        }
39                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
40                    },
41                    other => {
42                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
43                            "expected object key or end object, found: {:?}",
44                            other
45                        )))
46                    }
47                }
48            }
49            Ok(Some(
50                crate::serde_util::real_time_contact_analysis_transcript_item_with_content_correct_errors(builder)
51                    .build()
52                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
53            ))
54        }
55        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
56            "expected start object or null",
57        )),
58    }
59}