aws-sdk-migrationhubstrategy 0.27.0

AWS SDK for Migration Hub Strategy Recommendations
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_business_goals<'a, I>(
    tokens: &mut std::iter::Peekable<I>,
) -> Result<
    Option<crate::types::BusinessGoals>,
    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::BusinessGoalsBuilder::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() {
                            "speedOfMigration" => {
                                builder = builder.set_speed_of_migration(
                                    aws_smithy_json::deserialize::token::expect_number_or_null(
                                        tokens.next(),
                                    )?
                                    .map(i32::try_from)
                                    .transpose()?,
                                );
                            }
                            "reduceOperationalOverheadWithManagedServices" => {
                                builder = builder
                                    .set_reduce_operational_overhead_with_managed_services(
                                        aws_smithy_json::deserialize::token::expect_number_or_null(
                                            tokens.next(),
                                        )?
                                        .map(i32::try_from)
                                        .transpose()?,
                                    );
                            }
                            "modernizeInfrastructureWithCloudNativeTechnologies" => {
                                builder = builder
                                    .set_modernize_infrastructure_with_cloud_native_technologies(
                                        aws_smithy_json::deserialize::token::expect_number_or_null(
                                            tokens.next(),
                                        )?
                                        .map(i32::try_from)
                                        .transpose()?,
                                    );
                            }
                            "licenseCostReduction" => {
                                builder = builder.set_license_cost_reduction(
                                    aws_smithy_json::deserialize::token::expect_number_or_null(
                                        tokens.next(),
                                    )?
                                    .map(i32::try_from)
                                    .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(builder.build()))
        }
        _ => Err(
            aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ),
        ),
    }
}

pub fn ser_business_goals(
    object: &mut aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::BusinessGoals,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
    if let Some(var_1) = &input.speed_of_migration {
        object.key("speedOfMigration").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_1).into()),
        );
    }
    if let Some(var_2) = &input.reduce_operational_overhead_with_managed_services {
        object
            .key("reduceOperationalOverheadWithManagedServices")
            .number(
                #[allow(clippy::useless_conversion)]
                aws_smithy_types::Number::NegInt((*var_2).into()),
            );
    }
    if let Some(var_3) = &input.modernize_infrastructure_with_cloud_native_technologies {
        object
            .key("modernizeInfrastructureWithCloudNativeTechnologies")
            .number(
                #[allow(clippy::useless_conversion)]
                aws_smithy_types::Number::NegInt((*var_3).into()),
            );
    }
    if let Some(var_4) = &input.license_cost_reduction {
        object.key("licenseCostReduction").number(
            #[allow(clippy::useless_conversion)]
            aws_smithy_types::Number::NegInt((*var_4).into()),
        );
    }
    Ok(())
}