aws-sdk-lexmodelsv2 1.110.0

AWS SDK for Amazon Lex Model Building V2
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_nlu_improvement_specification<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::NluImprovementSpecification>, ::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::NluImprovementSpecificationBuilder::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() {
                        "enabled" => {
                            builder = builder.set_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
                        }
                        "assistedNluMode" => {
                            builder = builder.set_assisted_nlu_mode(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::AssistedNluMode::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "intentDisambiguationSettings" => {
                            builder = builder.set_intent_disambiguation_settings(
                                crate::protocol_serde::shape_intent_disambiguation_settings::de_intent_disambiguation_settings(tokens, _value)?,
                            );
                        }
                        _ => ::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::nlu_improvement_specification_correct_errors(builder).build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}

pub fn ser_nlu_improvement_specification(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::NluImprovementSpecification,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    {
        object.key("enabled").boolean(input.enabled);
    }
    if let Some(var_1) = &input.assisted_nlu_mode {
        object.key("assistedNluMode").string(var_1.as_str());
    }
    if let Some(var_2) = &input.intent_disambiguation_settings {
        #[allow(unused_mut)]
        let mut object_3 = object.key("intentDisambiguationSettings").start_object();
        crate::protocol_serde::shape_intent_disambiguation_settings::ser_intent_disambiguation_settings(&mut object_3, var_2)?;
        object_3.finish();
    }
    Ok(())
}