Skip to main content

aws_sdk_quicksight/protocol_serde/
shape_aggregation_sort_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_aggregation_sort_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::AggregationSortConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.column {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("Column").start_object();
9        crate::protocol_serde::shape_column_identifier::ser_column_identifier(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    {
13        object.key("SortDirection").string(input.sort_direction.as_str());
14    }
15    if let Some(var_3) = &input.aggregation_function {
16        #[allow(unused_mut)]
17        let mut object_4 = object.key("AggregationFunction").start_object();
18        crate::protocol_serde::shape_aggregation_function::ser_aggregation_function(&mut object_4, var_3)?;
19        object_4.finish();
20    }
21    Ok(())
22}
23
24pub(crate) fn de_aggregation_sort_configuration<'a, I>(
25    tokens: &mut ::std::iter::Peekable<I>,
26    _value: &'a [u8],
27) -> ::std::result::Result<Option<crate::types::AggregationSortConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
28where
29    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
30{
31    match tokens.next().transpose()? {
32        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
33        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
34            #[allow(unused_mut)]
35            let mut builder = crate::types::builders::AggregationSortConfigurationBuilder::default();
36            loop {
37                match tokens.next().transpose()? {
38                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
39                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
40                        "Column" => {
41                            builder = builder.set_column(crate::protocol_serde::shape_column_identifier::de_column_identifier(tokens, _value)?);
42                        }
43                        "SortDirection" => {
44                            builder = builder.set_sort_direction(
45                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
46                                    .map(|s| s.to_unescaped().map(|u| crate::types::SortDirection::from(u.as_ref())))
47                                    .transpose()?,
48                            );
49                        }
50                        "AggregationFunction" => {
51                            builder = builder.set_aggregation_function(crate::protocol_serde::shape_aggregation_function::de_aggregation_function(
52                                tokens, _value,
53                            )?);
54                        }
55                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
56                    },
57                    other => {
58                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
59                            "expected object key or end object, found: {other:?}"
60                        )))
61                    }
62                }
63            }
64            Ok(Some(
65                crate::serde_util::aggregation_sort_configuration_correct_errors(builder)
66                    .build()
67                    .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
68            ))
69        }
70        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
71            "expected start object or null",
72        )),
73    }
74}