Skip to main content

aws_sdk_glue/protocol_serde/
shape_s3_catalog_source.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_s3_catalog_source(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::S3CatalogSource,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("Name").string(input.name.as_str());
8    }
9    {
10        object.key("Database").string(input.database.as_str());
11    }
12    {
13        object.key("Table").string(input.table.as_str());
14    }
15    if let Some(var_1) = &input.partition_predicate {
16        object.key("PartitionPredicate").string(var_1.as_str());
17    }
18    if let Some(var_2) = &input.additional_options {
19        #[allow(unused_mut)]
20        let mut object_3 = object.key("AdditionalOptions").start_object();
21        crate::protocol_serde::shape_s3_source_additional_options::ser_s3_source_additional_options(&mut object_3, var_2)?;
22        object_3.finish();
23    }
24    Ok(())
25}
26
27pub(crate) fn de_s3_catalog_source<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29    _value: &'a [u8],
30) -> ::std::result::Result<Option<crate::types::S3CatalogSource>, ::aws_smithy_json::deserialize::error::DeserializeError>
31where
32    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
33{
34    match tokens.next().transpose()? {
35        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
36        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
37            #[allow(unused_mut)]
38            let mut builder = crate::types::builders::S3CatalogSourceBuilder::default();
39            loop {
40                match tokens.next().transpose()? {
41                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
42                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
43                        "Name" => {
44                            builder = builder.set_name(
45                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
46                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
47                                    .transpose()?,
48                            );
49                        }
50                        "Database" => {
51                            builder = builder.set_database(
52                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
53                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
54                                    .transpose()?,
55                            );
56                        }
57                        "Table" => {
58                            builder = builder.set_table(
59                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
60                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
61                                    .transpose()?,
62                            );
63                        }
64                        "PartitionPredicate" => {
65                            builder = builder.set_partition_predicate(
66                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
67                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
68                                    .transpose()?,
69                            );
70                        }
71                        "AdditionalOptions" => {
72                            builder = builder.set_additional_options(
73                                crate::protocol_serde::shape_s3_source_additional_options::de_s3_source_additional_options(tokens, _value)?,
74                            );
75                        }
76                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
77                    },
78                    other => {
79                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
80                            "expected object key or end object, found: {other:?}"
81                        )))
82                    }
83                }
84            }
85            Ok(Some(crate::serde_util::s3_catalog_source_correct_errors(builder).build().map_err(
86                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
87            )?))
88        }
89        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
90            "expected start object or null",
91        )),
92    }
93}