Skip to main content

aws_sdk_quicksight/protocol_serde/
shape_logical_table_source.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_logical_table_source(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::LogicalTableSource,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.join_instruction {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("JoinInstruction").start_object();
9        crate::protocol_serde::shape_join_instruction::ser_join_instruction(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.physical_table_id {
13        object.key("PhysicalTableId").string(var_3.as_str());
14    }
15    if let Some(var_4) = &input.data_set_arn {
16        object.key("DataSetArn").string(var_4.as_str());
17    }
18    Ok(())
19}
20
21pub(crate) fn de_logical_table_source<'a, I>(
22    tokens: &mut ::std::iter::Peekable<I>,
23    _value: &'a [u8],
24) -> ::std::result::Result<Option<crate::types::LogicalTableSource>, ::aws_smithy_json::deserialize::error::DeserializeError>
25where
26    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
27{
28    match tokens.next().transpose()? {
29        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
30        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
31            #[allow(unused_mut)]
32            let mut builder = crate::types::builders::LogicalTableSourceBuilder::default();
33            loop {
34                match tokens.next().transpose()? {
35                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
36                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
37                        "JoinInstruction" => {
38                            builder =
39                                builder.set_join_instruction(crate::protocol_serde::shape_join_instruction::de_join_instruction(tokens, _value)?);
40                        }
41                        "PhysicalTableId" => {
42                            builder = builder.set_physical_table_id(
43                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
44                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
45                                    .transpose()?,
46                            );
47                        }
48                        "DataSetArn" => {
49                            builder = builder.set_data_set_arn(
50                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
51                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
52                                    .transpose()?,
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(builder.build()))
65        }
66        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
67            "expected start object or null",
68        )),
69    }
70}