Skip to main content

aws_sdk_quicksight/protocol_serde/
shape_pie_chart_sort_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_pie_chart_sort_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::PieChartSortConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.category_sort {
7        let mut array_2 = object.key("CategorySort").start_array();
8        for item_3 in var_1 {
9            {
10                #[allow(unused_mut)]
11                let mut object_4 = array_2.value().start_object();
12                crate::protocol_serde::shape_field_sort_options::ser_field_sort_options(&mut object_4, item_3)?;
13                object_4.finish();
14            }
15        }
16        array_2.finish();
17    }
18    if let Some(var_5) = &input.category_items_limit {
19        #[allow(unused_mut)]
20        let mut object_6 = object.key("CategoryItemsLimit").start_object();
21        crate::protocol_serde::shape_items_limit_configuration::ser_items_limit_configuration(&mut object_6, var_5)?;
22        object_6.finish();
23    }
24    if let Some(var_7) = &input.small_multiples_sort {
25        let mut array_8 = object.key("SmallMultiplesSort").start_array();
26        for item_9 in var_7 {
27            {
28                #[allow(unused_mut)]
29                let mut object_10 = array_8.value().start_object();
30                crate::protocol_serde::shape_field_sort_options::ser_field_sort_options(&mut object_10, item_9)?;
31                object_10.finish();
32            }
33        }
34        array_8.finish();
35    }
36    if let Some(var_11) = &input.small_multiples_limit_configuration {
37        #[allow(unused_mut)]
38        let mut object_12 = object.key("SmallMultiplesLimitConfiguration").start_object();
39        crate::protocol_serde::shape_items_limit_configuration::ser_items_limit_configuration(&mut object_12, var_11)?;
40        object_12.finish();
41    }
42    Ok(())
43}
44
45pub(crate) fn de_pie_chart_sort_configuration<'a, I>(
46    tokens: &mut ::std::iter::Peekable<I>,
47    _value: &'a [u8],
48) -> ::std::result::Result<Option<crate::types::PieChartSortConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
49where
50    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
51{
52    match tokens.next().transpose()? {
53        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
54        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
55            #[allow(unused_mut)]
56            let mut builder = crate::types::builders::PieChartSortConfigurationBuilder::default();
57            loop {
58                match tokens.next().transpose()? {
59                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
60                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
61                        "CategorySort" => {
62                            builder = builder.set_category_sort(crate::protocol_serde::shape_field_sort_options_list::de_field_sort_options_list(
63                                tokens, _value,
64                            )?);
65                        }
66                        "CategoryItemsLimit" => {
67                            builder = builder.set_category_items_limit(
68                                crate::protocol_serde::shape_items_limit_configuration::de_items_limit_configuration(tokens, _value)?,
69                            );
70                        }
71                        "SmallMultiplesSort" => {
72                            builder = builder.set_small_multiples_sort(
73                                crate::protocol_serde::shape_field_sort_options_list::de_field_sort_options_list(tokens, _value)?,
74                            );
75                        }
76                        "SmallMultiplesLimitConfiguration" => {
77                            builder = builder.set_small_multiples_limit_configuration(
78                                crate::protocol_serde::shape_items_limit_configuration::de_items_limit_configuration(tokens, _value)?,
79                            );
80                        }
81                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
82                    },
83                    other => {
84                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
85                            "expected object key or end object, found: {other:?}"
86                        )))
87                    }
88                }
89            }
90            Ok(Some(builder.build()))
91        }
92        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
93            "expected start object or null",
94        )),
95    }
96}