aws-sdk-gamelift 1.118.0

AWS SDK for Amazon GameLift
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_priority_configuration(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::PriorityConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    if let Some(var_1) = &input.priority_order {
        encoder.str("PriorityOrder");
        encoder.array((*var_1).len());
        for item_2 in var_1 {
            {
                encoder.str(item_2.as_str());
            }
        }
    }
    if let Some(var_3) = &input.location_order {
        encoder.str("LocationOrder");
        encoder.array((*var_3).len());
        for item_4 in var_3 {
            {
                encoder.str(item_4.as_str());
            }
        }
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_priority_configuration(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::PriorityConfiguration, ::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::PriorityConfigurationBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::builders::PriorityConfigurationBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "PriorityOrder" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(
                    builder.set_priority_order(Some(crate::protocol_serde::shape_priority_type_list::de_priority_type_list(
                        decoder,
                        depth + 1,
                    )?)),
                )
            })?,
            "LocationOrder" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder.set_location_order(Some(crate::protocol_serde::shape_location_list::de_location_list(decoder, depth + 1)?)))
            })?,
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

    let mut builder = crate::types::builders::PriorityConfigurationBuilder::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());
    }
}