aws-sdk-cloudwatch 1.109.0

AWS SDK for Amazon CloudWatch
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_evaluation_criteria(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    input: &crate::types::EvaluationCriteria,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.map(1);
    match input {
        crate::types::EvaluationCriteria::PromQlCriteria(inner) => {
            encoder.str("PromQLCriteria");
            crate::protocol_serde::shape_alarm_prom_ql_criteria::ser_alarm_prom_ql_criteria(encoder, inner)?;
        }
        crate::types::EvaluationCriteria::Unknown => {
            return ::std::result::Result::Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "EvaluationCriteria",
            ))
        }
    }
    ::std::result::Result::Ok(())
}

pub(crate) fn de_evaluation_criteria(
    decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<crate::types::EvaluationCriteria, ::aws_smithy_cbor::decode::DeserializeError> {
    fn pair(
        decoder: &mut ::aws_smithy_cbor::Decoder,
    ) -> ::std::result::Result<crate::types::EvaluationCriteria, ::aws_smithy_cbor::decode::DeserializeError> {
        Ok(match decoder.str()?.as_ref() {
            "PromQLCriteria" => crate::types::EvaluationCriteria::PromQlCriteria(
                crate::protocol_serde::shape_alarm_prom_ql_criteria::de_alarm_prom_ql_criteria(decoder)?,
            ),
            _ => {
                decoder.skip()?;
                crate::types::EvaluationCriteria::Unknown
            }
        })
    }

    match decoder.map()? {
        None => {
            let variant = pair(decoder)?;
            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),
        Some(_) => Err(::aws_smithy_cbor::decode::DeserializeError::mixed_union_variants(decoder.position())),
    }
}