aws-sdk-qconnect 1.109.0

AWS SDK for Amazon Q Connect
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_data_details<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::DataDetails>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    let mut variant = None;
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                        if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
                            tokens.peek()
                        {
                            let _ = tokens.next().expect("peek returned a token")?;
                            continue;
                        }
                        let key = key.to_unescaped()?;
                        if key == "__type" {
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                            continue;
                        }
                        if variant.is_some() {
                            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                                "encountered mixed variants in union",
                            ));
                        }
                        variant = match key.as_ref() {
                            "contentData" => {
                                Some(crate::types::DataDetails::ContentData(
                                    crate::protocol_serde::shape_content_data_details::de_content_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'contentData' cannot be null"))?
                                ))
                            }
                            "generativeData" => {
                                Some(crate::types::DataDetails::GenerativeData(
                                    crate::protocol_serde::shape_generative_data_details::de_generative_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'generativeData' cannot be null"))?
                                ))
                            }
                            "intentDetectedData" => {
                                Some(crate::types::DataDetails::IntentDetectedData(
                                    crate::protocol_serde::shape_intent_detected_data_details::de_intent_detected_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'intentDetectedData' cannot be null"))?
                                ))
                            }
                            "sourceContentData" => {
                                Some(crate::types::DataDetails::SourceContentData(
                                    crate::protocol_serde::shape_source_content_data_details::de_source_content_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'sourceContentData' cannot be null"))?
                                ))
                            }
                            "generativeChunkData" => {
                                Some(crate::types::DataDetails::GenerativeChunkData(
                                    crate::protocol_serde::shape_generative_chunk_data_details::de_generative_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'generativeChunkData' cannot be null"))?
                                ))
                            }
                            "emailResponseChunkData" => {
                                Some(crate::types::DataDetails::EmailResponseChunkData(
                                    crate::protocol_serde::shape_email_response_chunk_data_details::de_email_response_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'emailResponseChunkData' cannot be null"))?
                                ))
                            }
                            "emailOverviewChunkData" => {
                                Some(crate::types::DataDetails::EmailOverviewChunkData(
                                    crate::protocol_serde::shape_email_overview_chunk_data_details::de_email_overview_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'emailOverviewChunkData' cannot be null"))?
                                ))
                            }
                            "emailGenerativeAnswerChunkData" => {
                                Some(crate::types::DataDetails::EmailGenerativeAnswerChunkData(
                                    crate::protocol_serde::shape_email_generative_answer_chunk_data_details::de_email_generative_answer_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'emailGenerativeAnswerChunkData' cannot be null"))?
                                ))
                            }
                            "caseSummarizationChunkData" => {
                                Some(crate::types::DataDetails::CaseSummarizationChunkData(
                                    crate::protocol_serde::shape_case_summarization_chunk_data_details::de_case_summarization_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'caseSummarizationChunkData' cannot be null"))?
                                ))
                            }
                            "suggestedMessageData" => {
                                Some(crate::types::DataDetails::SuggestedMessageData(
                                    crate::protocol_serde::shape_suggested_message_data_details::de_suggested_message_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'suggestedMessageData' cannot be null"))?
                                ))
                            }
                            "notesData" => {
                                Some(crate::types::DataDetails::NotesData(
                                    crate::protocol_serde::shape_notes_data_details::de_notes_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'notesData' cannot be null"))?
                                ))
                            }
                            "notesChunkData" => {
                                Some(crate::types::DataDetails::NotesChunkData(
                                    crate::protocol_serde::shape_notes_chunk_data_details::de_notes_chunk_data_details(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'notesChunkData' cannot be null"))?
                                ))
                            }
                            _ => {
                                                                              ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                                                                              Some(crate::types::DataDetails::Unknown)
                                                                            }
                        };
                    }
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
        }
        _ => {
            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ))
        }
    }
    if variant.is_none() {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "Union did not contain a valid variant.",
        ));
    }
    Ok(variant)
}