aws-sdk-imagebuilder 1.110.0

AWS SDK for EC2 Image Builder
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_fast_launch_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::FastLaunchConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    {
        object.key("enabled").boolean(input.enabled);
    }
    if let Some(var_1) = &input.snapshot_configuration {
        #[allow(unused_mut)]
        let mut object_2 = object.key("snapshotConfiguration").start_object();
        crate::protocol_serde::shape_fast_launch_snapshot_configuration::ser_fast_launch_snapshot_configuration(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.max_parallel_launches {
        object.key("maxParallelLaunches").number(
            #[allow(clippy::useless_conversion)]
            ::aws_smithy_types::Number::NegInt((*var_3).into()),
        );
    }
    if let Some(var_4) = &input.launch_template {
        #[allow(unused_mut)]
        let mut object_5 = object.key("launchTemplate").start_object();
        crate::protocol_serde::shape_fast_launch_launch_template_specification::ser_fast_launch_launch_template_specification(&mut object_5, var_4)?;
        object_5.finish();
    }
    if let Some(var_6) = &input.account_id {
        object.key("accountId").string(var_6.as_str());
    }
    Ok(())
}

pub(crate) fn de_fast_launch_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::FastLaunchConfiguration>, ::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::FastLaunchConfigurationBuilder::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())?);
                            }
                            "snapshotConfiguration" => {
                                builder = builder.set_snapshot_configuration(
                                    crate::protocol_serde::shape_fast_launch_snapshot_configuration::de_fast_launch_snapshot_configuration(
                                        tokens, _value,
                                    )?,
                                );
                            }
                            "maxParallelLaunches" => {
                                builder = builder.set_max_parallel_launches(
                                    ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
                                        .map(i32::try_from)
                                        .transpose()?,
                                );
                            }
                            "launchTemplate" => {
                                builder = builder.set_launch_template(
                                    crate::protocol_serde::shape_fast_launch_launch_template_specification::de_fast_launch_launch_template_specification(tokens, _value)?
                                );
                            }
                            "accountId" => {
                                builder = builder.set_account_id(
                                    ::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::fast_launch_configuration_correct_errors(builder).build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}