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_font_configuration(
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    input: &crate::types::FontConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    if let Some(var_1) = &input.font_size {
        #[allow(unused_mut)]
        let mut object_2 = object.key("FontSize").start_object();
        crate::protocol_serde::shape_font_size::ser_font_size(&mut object_2, var_1)?;
        object_2.finish();
    }
    if let Some(var_3) = &input.font_decoration {
        object.key("FontDecoration").string(var_3.as_str());
    }
    if let Some(var_4) = &input.font_color {
        object.key("FontColor").string(var_4.as_str());
    }
    if let Some(var_5) = &input.font_weight {
        #[allow(unused_mut)]
        let mut object_6 = object.key("FontWeight").start_object();
        crate::protocol_serde::shape_font_weight::ser_font_weight(&mut object_6, var_5)?;
        object_6.finish();
    }
    if let Some(var_7) = &input.font_style {
        object.key("FontStyle").string(var_7.as_str());
    }
    if let Some(var_8) = &input.font_family {
        object.key("FontFamily").string(var_8.as_str());
    }
    Ok(())
}

pub(crate) fn de_font_configuration<'a, I>(
    tokens: &mut ::std::iter::Peekable<I>,
    _value: &'a [u8],
) -> ::std::result::Result<Option<crate::types::FontConfiguration>, ::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::FontConfigurationBuilder::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() {
                        "FontSize" => {
                            builder = builder.set_font_size(crate::protocol_serde::shape_font_size::de_font_size(tokens, _value)?);
                        }
                        "FontDecoration" => {
                            builder = builder.set_font_decoration(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::FontDecoration::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "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()?,
                            );
                        }
                        "FontWeight" => {
                            builder = builder.set_font_weight(crate::protocol_serde::shape_font_weight::de_font_weight(tokens, _value)?);
                        }
                        "FontStyle" => {
                            builder = builder.set_font_style(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| crate::types::FontStyle::from(u.as_ref())))
                                    .transpose()?,
                            );
                        }
                        "FontFamily" => {
                            builder = builder.set_font_family(
                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
                                    .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",
        )),
    }
}