aws-sdk-cloudwatch 1.120.0

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

pub(crate) fn de_evaluation_window(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::EvaluationWindow, ::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::EvaluationWindow, ::aws_smithy_cbor::decode::DeserializeError> {
        Ok(match decoder.str()?.as_ref() {
            "WallClockWindow" => crate::types::EvaluationWindow::WallClockWindow(
                crate::protocol_serde::shape_wall_clock_window::de_wall_clock_window(decoder, depth + 1)?,
            ),
            "SlidingWindow" => {
                crate::types::EvaluationWindow::SlidingWindow(crate::protocol_serde::shape_sliding_window::de_sliding_window(decoder, depth + 1)?)
            }
            _ => {
                decoder.skip()?;
                crate::types::EvaluationWindow::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())),
    }
}