aws-sdk-mailmanager 1.89.0

AWS SDK for MailManager
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_s3_action(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::S3Action,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    if let Some(var_1) = &input.action_failure_policy {
        encoder.str("ActionFailurePolicy").str(var_1.as_str());
    }
    {
        encoder.str("RoleArn").str(input.role_arn.as_str());
    }
    {
        encoder.str("S3Bucket").str(input.s3_bucket.as_str());
    }
    if let Some(var_2) = &input.s3_prefix {
        encoder.str("S3Prefix").str(var_2.as_str());
    }
    if let Some(var_3) = &input.s3_sse_kms_key_id {
        encoder.str("S3SseKmsKeyId").str(var_3.as_str());
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_s3_action(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::S3Action, ::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::S3ActionBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::builders::S3ActionBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "ActionFailurePolicy" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder.set_action_failure_policy(Some(decoder.string().map(|s| crate::types::ActionFailurePolicy::from(s.as_ref()))?)))
            })?,
            "RoleArn" => builder.set_role_arn(Some(decoder.string()?)),
            "S3Bucket" => builder.set_s3_bucket(Some(decoder.string()?)),
            "S3Prefix" => {
                ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| Ok(builder.set_s3_prefix(Some(decoder.string()?))))?
            }
            "S3SseKmsKeyId" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder.set_s3_sse_kms_key_id(Some(decoder.string()?)))
            })?,
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

    let mut builder = crate::types::builders::S3ActionBuilder::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(crate::serde_util::s3_action_correct_errors(builder)
            .build()
            .map_err(|err| ::aws_smithy_cbor::decode::DeserializeError::custom(err.to_string(), decoder.position()))?);
    }
}