aws-sdk-gamelift 1.119.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_override(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    #[allow(unused)] input: &crate::types::PriorityConfigurationOverride,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.begin_map();
    if let Some(var_1) = &input.placement_fallback_strategy {
        encoder.str("PlacementFallbackStrategy").str(var_1.as_str());
    }
    if let Some(var_2) = &input.location_order {
        encoder.str("LocationOrder");
        encoder.array((*var_2).len());
        for item_3 in var_2 {
            {
                encoder.str(item_3.as_str());
            }
        }
    }
    encoder.end();
    Ok(())
}

pub(crate) fn de_priority_configuration_override(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::PriorityConfigurationOverride, ::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::PriorityConfigurationOverrideBuilder,
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::builders::PriorityConfigurationOverrideBuilder, ::aws_smithy_cbor::decode::DeserializeError> {
        builder = match decoder.str()?.as_ref() {
            "PlacementFallbackStrategy" => ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
                Ok(builder
                    .set_placement_fallback_strategy(Some(decoder.string().map(|s| crate::types::PlacementFallbackStrategy::from(s.as_ref()))?)))
            })?,
            "LocationOrder" => builder.set_location_order(Some(
                crate::protocol_serde::shape_location_order_override_list::de_location_order_override_list(decoder, depth + 1)?,
            )),
            _ => {
                decoder.skip()?;
                builder
            }
        };
        Ok(builder)
    }

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