aws-sdk-quicksight 1.134.0

AWS SDK for Amazon QuickSight
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_reference_line_label_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::ReferenceLineLabelConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.value_label_configuration {
        #[allow(unused_mut)]
        let mut object_2 = object.key("ValueLabelConfiguration").start_object();
        crate::protocol_serde::shape_reference_line_value_label_configuration::ser_reference_line_value_label_configuration(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.custom_label_configuration {
        #[allow(unused_mut)]
        let mut object_4 = object.key("CustomLabelConfiguration").start_object();
        crate::protocol_serde::shape_reference_line_custom_label_configuration::ser_reference_line_custom_label_configuration(&mut object_4, var_3)?;
        object_4.finish();
    }
    if let Some(var_5) = &input.font_configuration {
        #[allow(unused_mut)]
        let mut object_6 = object.key("FontConfiguration").start_object();
        crate::protocol_serde::shape_font_configuration::ser_font_configuration(&mut object_6, var_5)?;
        object_6.finish();
    }
    if let Some(var_7) = &input.font_color {
        object.key("FontColor").string(var_7.as_str());
    }
    if let Some(var_8) = &input.horizontal_position {
        object.key("HorizontalPosition").string(var_8.as_str());
    }
    if let Some(var_9) = &input.vertical_position {
        object.key("VerticalPosition").string(var_9.as_str());
    }
    Ok(())
}

pub(crate) fn de_reference_line_label_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::ReferenceLineLabelConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
    match tokens.next().transpose()? {
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
            #[allow(unused_mut)]
            let mut builder = crate::types::builders::ReferenceLineLabelConfigurationBuilder::default();
            loop {
                match tokens.next().transpose()? {
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
                        match key.to_unescaped()?.as_ref() {
                            "ValueLabelConfiguration" => {
                                builder = builder.set_value_label_configuration(
                                    crate::protocol_serde::shape_reference_line_value_label_configuration::de_reference_line_value_label_configuration(tokens, _value)?
                                );
                            }
                            "CustomLabelConfiguration" => {
                                builder = builder.set_custom_label_configuration(
                                    crate::protocol_serde::shape_reference_line_custom_label_configuration::de_reference_line_custom_label_configuration(tokens, _value)?
                                );
                            }
                            "FontConfiguration" => {
                                builder = builder
                                    .set_font_configuration(crate::protocol_serde::shape_font_configuration::de_font_configuration(tokens, _value)?);
                            }
                            "FontColor" => {
                                builder = builder.set_font_color(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                        .transpose()?,
                                );
                            }
                            "HorizontalPosition" => {
                                builder = builder.set_horizontal_position(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                        .map(|s| {
                                            s.to_unescaped()
                                                .map(|u| crate::types::ReferenceLineLabelHorizontalPosition::from(u.as_ref()))
                                        })
                                        .transpose()?,
                                );
                            }
                            "VerticalPosition" => {
                                builder = builder.set_vertical_position(
                                    ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                        .map(|s| {
                                            s.to_unescaped()
                                                .map(|u| crate::types::ReferenceLineLabelVerticalPosition::from(u.as_ref()))
                                        })
                                        .transpose()?,
                                );
                            }
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
                        }
                    }
                    other => {
                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
                            "expected object key or end object, found: {other:?}"
                        )))
                    }
                }
            }
            Ok(Some(builder.build()))
        }
        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
            "expected start object or null",
        )),
    }
}