aws_sdk_voiceid/protocol_serde/
shape_authentication_result.rs1pub(crate) fn de_authentication_result<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4 _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::AuthenticationResult>, ::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::AuthenticationResultBuilder::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 "AuthenticationResultId" => {
19 builder = builder.set_authentication_result_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 "AudioAggregationStartedAt" => {
26 builder = builder.set_audio_aggregation_started_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
27 tokens.next(),
28 ::aws_smithy_types::date_time::Format::EpochSeconds,
29 )?);
30 }
31 "AudioAggregationEndedAt" => {
32 builder = builder.set_audio_aggregation_ended_at(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
33 tokens.next(),
34 ::aws_smithy_types::date_time::Format::EpochSeconds,
35 )?);
36 }
37 "CustomerSpeakerId" => {
38 builder = builder.set_customer_speaker_id(
39 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
40 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
41 .transpose()?,
42 );
43 }
44 "GeneratedSpeakerId" => {
45 builder = builder.set_generated_speaker_id(
46 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
47 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
48 .transpose()?,
49 );
50 }
51 "Decision" => {
52 builder = builder.set_decision(
53 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
54 .map(|s| s.to_unescaped().map(|u| crate::types::AuthenticationDecision::from(u.as_ref())))
55 .transpose()?,
56 );
57 }
58 "Score" => {
59 builder = builder.set_score(
60 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
61 .map(i32::try_from)
62 .transpose()?,
63 );
64 }
65 "Configuration" => {
66 builder = builder.set_configuration(
67 crate::protocol_serde::shape_authentication_configuration::de_authentication_configuration(tokens, _value)?,
68 );
69 }
70 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
71 },
72 other => {
73 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
74 "expected object key or end object, found: {other:?}"
75 )))
76 }
77 }
78 }
79 Ok(Some(builder.build()))
80 }
81 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
82 "expected start object or null",
83 )),
84 }
85}