aws-sdk-deadline 1.100.0

AWS SDK for AWSDeadlineCloud
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_scheduling_configuration(
    object_16: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::SchedulingConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    match input {
        crate::types::SchedulingConfiguration::PriorityFifo(inner) => {
            #[allow(unused_mut)]
            let mut object_1 = object_16.key("priorityFifo").start_object();
            crate::protocol_serde::shape_priority_fifo_scheduling_configuration::ser_priority_fifo_scheduling_configuration(&mut object_1, inner)?;
            object_1.finish();
        }
        crate::types::SchedulingConfiguration::PriorityBalanced(inner) => {
            #[allow(unused_mut)]
            let mut object_2 = object_16.key("priorityBalanced").start_object();
            crate::protocol_serde::shape_priority_balanced_scheduling_configuration::ser_priority_balanced_scheduling_configuration(
                &mut object_2,
                inner,
            )?;
            object_2.finish();
        }
        crate::types::SchedulingConfiguration::WeightedBalanced(inner) => {
            #[allow(unused_mut)]
            let mut object_3 = object_16.key("weightedBalanced").start_object();
            crate::protocol_serde::shape_weighted_balanced_scheduling_configuration::ser_weighted_balanced_scheduling_configuration(
                &mut object_3,
                inner,
            )?;
            object_3.finish();
        }
        crate::types::SchedulingConfiguration::Unknown => {
            return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "SchedulingConfiguration",
            ))
        }
    }
    Ok(())
}

pub(crate) fn de_scheduling_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::SchedulingConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    let mut variant = None;
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                        if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
                            tokens.peek()
                        {
                            let _ = tokens.next().expect("peek returned a token")?;
                            continue;
                        }
                        let key = key.to_unescaped()?;
                        if key == "__type" {
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                            continue;
                        }
                        if variant.is_some() {
                            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                                "encountered mixed variants in union",
                            ));
                        }
                        variant = match key.as_ref() {
                            "priorityFifo" => {
                                Some(crate::types::SchedulingConfiguration::PriorityFifo(
                                    crate::protocol_serde::shape_priority_fifo_scheduling_configuration::de_priority_fifo_scheduling_configuration(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'priorityFifo' cannot be null"))?
                                ))
                            }
                            "priorityBalanced" => {
                                Some(crate::types::SchedulingConfiguration::PriorityBalanced(
                                    crate::protocol_serde::shape_priority_balanced_scheduling_configuration::de_priority_balanced_scheduling_configuration(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'priorityBalanced' cannot be null"))?
                                ))
                            }
                            "weightedBalanced" => {
                                Some(crate::types::SchedulingConfiguration::WeightedBalanced(
                                    crate::protocol_serde::shape_weighted_balanced_scheduling_configuration::de_weighted_balanced_scheduling_configuration(tokens, _value)?
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'weightedBalanced' cannot be null"))?
                                ))
                            }
                            _ => {
                                                                              ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
                                                                              Some(crate::types::SchedulingConfiguration::Unknown)
                                                                            }
                        };
                    }
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
        }
        _ => {
            return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
                "expected start object or null",
            ))
        }
    }
    if variant.is_none() {
        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "Union did not contain a valid variant.",
        ));
    }
    Ok(variant)
}