aws-sdk-apprunner 1.99.0

AWS SDK for AWS App Runner
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_code_configuration_values(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::CodeConfigurationValues,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    {
        object.key("Runtime").string(input.runtime.as_str());
    }
    if let Some(var_1) = &input.build_command {
        object.key("BuildCommand").string(var_1.as_str());
    }
    if let Some(var_2) = &input.start_command {
        object.key("StartCommand").string(var_2.as_str());
    }
    if let Some(var_3) = &input.port {
        object.key("Port").string(var_3.as_str());
    }
    if let Some(var_4) = &input.runtime_environment_variables {
        #[allow(unused_mut)]
        let mut object_5 = object.key("RuntimeEnvironmentVariables").start_object();
        for (key_6, value_7) in var_4 {
            {
                object_5.key(key_6.as_str()).string(value_7.as_str());
            }
        }
        object_5.finish();
    }
    if let Some(var_8) = &input.runtime_environment_secrets {
        #[allow(unused_mut)]
        let mut object_9 = object.key("RuntimeEnvironmentSecrets").start_object();
        for (key_10, value_11) in var_8 {
            {
                object_9.key(key_10.as_str()).string(value_11.as_str());
            }
        }
        object_9.finish();
    }
    Ok(())
}

pub(crate) fn de_code_configuration_values<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::CodeConfigurationValues>, ::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::CodeConfigurationValuesBuilder::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() {
                        "Runtime" => {
                            builder = builder.set_runtime(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::Runtime::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "BuildCommand" => {
                            builder = builder.set_build_command(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "StartCommand" => {
                            builder = builder.set_start_command(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Port" => {
                            builder = builder.set_port(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "RuntimeEnvironmentVariables" => {
                            builder = builder.set_runtime_environment_variables(
                                crate::protocol_serde::shape_runtime_environment_variables::de_runtime_environment_variables(tokens, _value)?,
                            );
                        }
                        "RuntimeEnvironmentSecrets" => {
                            builder = builder.set_runtime_environment_secrets(
                                crate::protocol_serde::shape_runtime_environment_secrets::de_runtime_environment_secrets(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::code_configuration_values_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",
        )),
    }
}