aws-sdk-cloudwatch 1.109.1

AWS SDK for Amazon CloudWatch
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_dimension(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::Dimension,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    if let Some(var_1) = &input.name {
        encoder.str("Name").str(var_1.as_str());
    }
    if let Some(var_2) = &input.value {
        encoder.str("Value").str(var_2.as_str());
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_dimension(
    decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<crate::types::Dimension, ::aws_smithy_cbor::decode::DeserializeError> {
    #[allow(clippy::match_single_binding)]
    fn pair(
        mut builder: crate::types::builders::DimensionBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
    ) -> ::std::result::Result<crate::types::builders::DimensionBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "Name" => builder.set_name(Some(decoder.string()?)),
            "Value" => builder.set_value(Some(decoder.string()?)),
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

    let mut builder = crate::types::builders::DimensionBuilder::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::dimension_correct_errors(builder).build());
    }
}