Skip to main content

aws_sdk_connect/protocol_serde/
shape_real_time_contact_analysis_segment_transcript.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_real_time_contact_analysis_segment_transcript<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4    _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::RealTimeContactAnalysisSegmentTranscript>, ::aws_smithy_json::deserialize::error::DeserializeError>
6where
7    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
8{
9    match tokens.next().transpose()? {
10        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
11        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
12            #[allow(unused_mut)]
13            let mut builder = crate::types::builders::RealTimeContactAnalysisSegmentTranscriptBuilder::default();
14            loop {
15                match tokens.next().transpose()? {
16                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
17                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
18                        "Id" => {
19                            builder = builder.set_id(
20                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
21                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
22                                    .transpose()?,
23                            );
24                        }
25                        "ParticipantId" => {
26                            builder = builder.set_participant_id(
27                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
28                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
29                                    .transpose()?,
30                            );
31                        }
32                        "ParticipantRole" => {
33                            builder = builder.set_participant_role(
34                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
35                                    .map(|s| s.to_unescaped().map(|u| crate::types::ParticipantRole::from(u.as_ref())))
36                                    .transpose()?,
37                            );
38                        }
39                        "DisplayName" => {
40                            builder = builder.set_display_name(
41                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43                                    .transpose()?,
44                            );
45                        }
46                        "Content" => {
47                            builder = builder.set_content(
48                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
50                                    .transpose()?,
51                            );
52                        }
53                        "ContentType" => {
54                            builder = builder.set_content_type(
55                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
57                                    .transpose()?,
58                            );
59                        }
60                        "Time" => {
61                            builder = builder.set_time(
62                                crate::protocol_serde::shape_real_time_contact_analysis_time_data::de_real_time_contact_analysis_time_data(
63                                    tokens, _value,
64                                )?,
65                            );
66                        }
67                        "Redaction" => {
68                            builder = builder.set_redaction(
69                                    crate::protocol_serde::shape_real_time_contact_analysis_transcript_item_redaction::de_real_time_contact_analysis_transcript_item_redaction(tokens, _value)?
70                                );
71                        }
72                        "Sentiment" => {
73                            builder = builder.set_sentiment(
74                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
75                                    .map(|s| {
76                                        s.to_unescaped()
77                                            .map(|u| crate::types::RealTimeContactAnalysisSentimentLabel::from(u.as_ref()))
78                                    })
79                                    .transpose()?,
80                            );
81                        }
82                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
83                    },
84                    other => {
85                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
86                            "expected object key or end object, found: {other:?}"
87                        )))
88                    }
89                }
90            }
91            Ok(Some(
92                crate::serde_util::real_time_contact_analysis_segment_transcript_correct_errors(builder)
93                    .build()
94                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
95            ))
96        }
97        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
98            "expected start object or null",
99        )),
100    }
101}