aws-sdk-computeoptimizerautomation 1.9.0

AWS SDK for Compute Optimizer Automation
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub(crate) fn de_estimated_monthly_savings(
    decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<crate::types::EstimatedMonthlySavings, ::aws_smithy_cbor::decode::DeserializeError> {
    #[allow(clippy::match_single_binding)]
    fn pair(
        mut builder: crate::types::builders::EstimatedMonthlySavingsBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
    ) -> ::std::result::Result<crate::types::builders::EstimatedMonthlySavingsBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "currency" => builder.set_currency(Some(decoder.string()?)),
            "beforeDiscountSavings" => builder.set_before_discount_savings(Some(decoder.double()?)),
            "afterDiscountSavings" => builder.set_after_discount_savings(Some(decoder.double()?)),
            "savingsEstimationMode" => {
                builder.set_savings_estimation_mode(Some(decoder.string().map(|s| crate::types::SavingsEstimationMode::from(s.as_ref()))?))
            }
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

    let mut builder = crate::types::builders::EstimatedMonthlySavingsBuilder::default();

    match decoder.map()? {
        None => loop {
            match decoder.datatype()? {
                ::aws_smithy_cbor::data::Type::Break => {
                    decoder.skip()?;
                    break;
                }
                _ => {
                    builder = pair(builder, decoder)?;
                }
            };
        },
        Some(n) => {
            for _ in 0..n {
                builder = pair(builder, decoder)?;
            }
        }
    };
    #[allow(clippy::needless_question_mark)]
    {
        return Ok(crate::serde_util::estimated_monthly_savings_correct_errors(builder)
            .build()
            .map_err(|err| ::aws_smithy_cbor::decode::DeserializeError::custom(err.to_string(), decoder.position()))?);
    }
}