aws-sdk-cloudwatchomni 1.2.0

AWS SDK for CloudWatch Omni
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_scoped_actions(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::ScopedActions,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    {
        encoder.str("actions");
        encoder.array((input.actions).len());
        for item_1 in &input.actions {
            {
                encoder.str(item_1.as_str());
            }
        }
    }
    if let Some(var_2) = &input.resources {
        encoder.str("resources");
        encoder.array((*var_2).len());
        for item_3 in var_2 {
            {
                crate::protocol_serde::shape_resource_scope::ser_resource_scope(encoder, item_3)?;
            }
        }
    }
    if let Some(var_4) = &input.context_conditions {
        encoder.str("contextConditions");
        encoder.map((*var_4).len());
        for (key_5, value_6) in var_4 {
            {
                encoder.str(key_5.as_str());
                encoder.array((*value_6).len());
                for item_7 in value_6 {
                    {
                        encoder.str(item_7.as_str());
                    }
                }
            }
        }
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_scoped_actions(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::ScopedActions, ::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::ScopedActionsBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::builders::ScopedActionsBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "actions" => builder.set_actions(Some(crate::protocol_serde::shape_scoped_action_name_list::de_scoped_action_name_list(
                decoder,
                depth + 1,
            )?)),
            "resources" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(
                    builder.set_resources(Some(crate::protocol_serde::shape_resource_scope_list::de_resource_scope_list(
                        decoder,
                        depth + 1,
                    )?)),
                )
            })?,
            "contextConditions" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(
                    builder.set_context_conditions(Some(crate::protocol_serde::shape_context_conditions_map::de_context_conditions_map(
                        decoder,
                        depth + 1,
                    )?)),
                )
            })?,
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

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