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_legend_options(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::LegendOptions,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.visibility {
        object.key("Visibility").string(var_1.as_str());
    }
    if let Some(var_2) = &input.title {
        #[allow(unused_mut)]
        let mut object_3 = object.key("Title").start_object();
        crate::protocol_serde::shape_label_options::ser_label_options(&mut object_3, var_2)?;
        object_3.finish();
    }
    if let Some(var_4) = &input.position {
        object.key("Position").string(var_4.as_str());
    }
    if let Some(var_5) = &input.width {
        object.key("Width").string(var_5.as_str());
    }
    if let Some(var_6) = &input.height {
        object.key("Height").string(var_6.as_str());
    }
    if let Some(var_7) = &input.value_font_configuration {
        #[allow(unused_mut)]
        let mut object_8 = object.key("ValueFontConfiguration").start_object();
        crate::protocol_serde::shape_font_configuration::ser_font_configuration(&mut object_8, var_7)?;
        object_8.finish();
    }
    Ok(())
}

pub(crate) fn de_legend_options<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::LegendOptions>, ::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::LegendOptionsBuilder::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() {
                        "Visibility" => {
                            builder = builder.set_visibility(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::Visibility::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "Title" => {
                            builder = builder.set_title(crate::protocol_serde::shape_label_options::de_label_options(tokens, _value)?);
                        }
                        "Position" => {
                            builder = builder.set_position(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::LegendPosition::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "Width" => {
                            builder = builder.set_width(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "Height" => {
                            builder = builder.set_height(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .transpose()?,
                            );
                        }
                        "ValueFontConfiguration" => {
                            builder = builder.set_value_font_configuration(crate::protocol_serde::shape_font_configuration::de_font_configuration(
                                tokens, _value,
                            )?);
                        }
                        _ => ::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",
        )),
    }
}