aws-sdk-lexruntime 1.98.0

AWS SDK for Amazon Lex Runtime Service
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_intent_summary(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::IntentSummary,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.intent_name {
        object.key("intentName").string(var_1.as_str());
    }
    if let Some(var_2) = &input.checkpoint_label {
        object.key("checkpointLabel").string(var_2.as_str());
    }
    if let Some(var_3) = &input.slots {
        #[allow(unused_mut)]
        let mut object_4 = object.key("slots").start_object();
        for (key_5, value_6) in var_3 {
            {
                object_4.key(key_5.as_str()).string(value_6.as_str());
            }
        }
        object_4.finish();
    }
    if let Some(var_7) = &input.confirmation_status {
        object.key("confirmationStatus").string(var_7.as_str());
    }
    {
        object.key("dialogActionType").string(input.dialog_action_type.as_str());
    }
    if let Some(var_8) = &input.fulfillment_state {
        object.key("fulfillmentState").string(var_8.as_str());
    }
    if let Some(var_9) = &input.slot_to_elicit {
        object.key("slotToElicit").string(var_9.as_str());
    }
    Ok(())
}

pub(crate) fn de_intent_summary<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::IntentSummary>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::IntentSummaryBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
                        "intentName" => {
                            builder = builder.set_intent_name(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "checkpointLabel" => {
                            builder = builder.set_checkpoint_label(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "slots" => {
                            builder = builder.set_slots(crate::protocol_serde::shape_string_map::de_string_map(tokens, _value)?);
                        }
                        "confirmationStatus" => {
                            builder = builder.set_confirmation_status(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::ConfirmationStatus::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "dialogActionType" => {
                            builder = builder.set_dialog_action_type(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::DialogActionType::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "fulfillmentState" => {
                            builder = builder.set_fulfillment_state(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::FulfillmentState::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "slotToElicit" => {
                            builder = builder.set_slot_to_elicit(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                    },
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
            Ok(Some(crate::serde_util::intent_summary_correct_errors(builder).build().map_err(
                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
            )?))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}