aws-sdk-mailmanager 1.89.0

AWS SDK for MailManager
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_rule_number_to_evaluate(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    input: &crate::types::RuleNumberToEvaluate,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.map(1);
    match input {
        crate::types::RuleNumberToEvaluate::Attribute(inner) => {
            encoder.str("Attribute").str(inner.as_str());
        }
        crate::types::RuleNumberToEvaluate::Unknown => {
            return ::std::result::Result::Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "RuleNumberToEvaluate",
            ))
        }
    }
    ::std::result::Result::Ok(())
}

pub(crate) fn de_rule_number_to_evaluate(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::RuleNumberToEvaluate, ::aws_smithy_cbor::decode::DeserializeError> {
    if depth >= 128u32 {
        return Err(::aws_smithy_cbor::decode::DeserializeError::custom(
            "maximum nesting depth exceeded",
            decoder.position(),
        ));
    }

    #[allow(unused_variables)]
    fn pair(
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::RuleNumberToEvaluate, ::aws_smithy_cbor::decode::DeserializeError> {
        Ok(match decoder.str()?.as_ref() {
            "Attribute" => {
                crate::types::RuleNumberToEvaluate::Attribute(decoder.string().map(|s| crate::types::RuleNumberEmailAttribute::from(s.as_ref()))?)
            }
            _ => {
                decoder.skip()?;
                crate::types::RuleNumberToEvaluate::Unknown
            }
        })
    }

    match decoder.map()? {
        None => {
            let variant = pair(decoder, depth)?;
            match decoder.datatype()? {
                ::aws_smithy_cbor::data::Type::Break => {
                    decoder.skip()?;
                    Ok(variant)
                }
                ty => Err(::aws_smithy_cbor::decode::DeserializeError::unexpected_union_variant(
                    ty,
                    decoder.position(),
                )),
            }
        }
        Some(1) => pair(decoder, depth),
        Some(_) => Err(::aws_smithy_cbor::decode::DeserializeError::mixed_union_variants(decoder.position())),
    }
}