aws-sdk-applicationsignals 1.80.0

AWS SDK for Amazon CloudWatch Application Signals
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_exclusion_window(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::ExclusionWindow,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.window {
        #[allow(unused_mut)]
        let mut object_2 = object.key("Window").start_object();
        crate::protocol_serde::shape_window::ser_window(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.start_time {
        object
            .key("StartTime")
            .date_time(var_3, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
    }
    if let Some(var_4) = &input.recurrence_rule {
        #[allow(unused_mut)]
        let mut object_5 = object.key("RecurrenceRule").start_object();
        crate::protocol_serde::shape_recurrence_rule::ser_recurrence_rule(&mut object_5, var_4)?;
        object_5.finish();
    }
    if let Some(var_6) = &input.reason {
        object.key("Reason").string(var_6.as_str());
    }
    Ok(())
}

pub(crate) fn de_exclusion_window<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ExclusionWindow>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::ExclusionWindowBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
                        "Window" => {
                            builder = builder.set_window(crate::protocol_serde::shape_window::de_window(tokens, _value)?);
                        }
                        "StartTime" => {
                            builder = builder.set_start_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
                                tokens.next(),
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
                            )?);
                        }
                        "RecurrenceRule" => {
                            builder = builder.set_recurrence_rule(crate::protocol_serde::shape_recurrence_rule::de_recurrence_rule(tokens, _value)?);
                        }
                        "Reason" => {
                            builder = builder.set_reason(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                    },
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
            Ok(Some(crate::serde_util::exclusion_window_correct_errors(builder).build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}