aws-sdk-imagebuilder 1.111.0

AWS SDK for EC2 Image Builder
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_schedule(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::Schedule,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.schedule_expression {
        object.key("scheduleExpression").string(var_1.as_str());
    }
    if let Some(var_2) = &input.timezone {
        object.key("timezone").string(var_2.as_str());
    }
    if let Some(var_3) = &input.pipeline_execution_start_condition {
        object.key("pipelineExecutionStartCondition").string(var_3.as_str());
    }
    if let Some(var_4) = &input.auto_disable_policy {
        #[allow(unused_mut)]
        let mut object_5 = object.key("autoDisablePolicy").start_object();
        crate::protocol_serde::shape_auto_disable_policy::ser_auto_disable_policy(&mut object_5, var_4)?;
        object_5.finish();
    }
    Ok(())
}

pub(crate) fn de_schedule<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::Schedule>, ::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::ScheduleBuilder::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() {
                        "scheduleExpression" => {
                            builder = builder.set_schedule_expression(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "timezone" => {
                            builder = builder.set_timezone(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "pipelineExecutionStartCondition" => {
                            builder = builder.set_pipeline_execution_start_condition(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::PipelineExecutionStartCondition::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "autoDisablePolicy" => {
                            builder = builder
                                .set_auto_disable_policy(crate::protocol_serde::shape_auto_disable_policy::de_auto_disable_policy(tokens, _value)?);
                        }
                        _ => ::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(builder.build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}