aws-sdk-snowball 1.105.0

AWS SDK for Amazon Import/Export Snowball
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_notification(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::Notification,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    if let Some(var_1) = &input.sns_topic_arn {
        encoder.str("SnsTopicARN").str(var_1.as_str());
    }
    if let Some(var_2) = &input.job_states_to_notify {
        encoder.str("JobStatesToNotify");
        encoder.array((*var_2).len());
        for item_3 in var_2 {
            {
                encoder.str(item_3.as_str());
            }
        }
    }
    if input.notify_all {
        encoder.str("NotifyAll").boolean(input.notify_all);
    }
    if let Some(var_4) = &input.device_pickup_sns_topic_arn {
        encoder.str("DevicePickupSnsTopicARN").str(var_4.as_str());
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_notification(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::Notification, ::aws_smithy_cbor::decode::DeserializeError> {
    if depth >= 128u32 {
        return Err(::aws_smithy_cbor::decode::DeserializeError::custom(
            "maximum nesting depth exceeded",
            decoder.position(),
        ));
    }
    #[allow(clippy::match_single_binding, unused_variables)]
    fn pair(
        mut builder: crate::types::builders::NotificationBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::builders::NotificationBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "SnsTopicARN" => {
                ::aws_smithy_cbor::decode::set_optional(
                    builder,
                    decoder,
                    |builder, decoder| Ok(builder.set_sns_topic_arn(Some(decoder.string()?))),
                )?
            }
            "JobStatesToNotify" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder.set_job_states_to_notify(Some(crate::protocol_serde::shape_job_state_list::de_job_state_list(decoder, depth + 1)?)))
            })?,
            "NotifyAll" => {
                ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_notify_all(Some(decoder.boolean()?))))?
            }
            "DevicePickupSnsTopicARN" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder.set_device_pickup_sns_topic_arn(Some(decoder.string()?)))
            })?,
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

    let mut builder = crate::types::builders::NotificationBuilder::default();

    match decoder.map()? {
        None => loop {
            match decoder.datatype()? {
                ::aws_smithy_cbor::data::Type::Break => {
                    decoder.skip()?;
                    break;
                }
                _ => {
                    builder = pair(builder, decoder, depth)?;
                }
            };
        },
        Some(n) => {
            for _ in 0..n {
                builder = pair(builder, decoder, depth)?;
            }
        }
    };
    #[allow(clippy::needless_question_mark)]
    {
        return Ok(builder.build());
    }
}