aws_sdk_glue/protocol_serde/
shape_catalog_source.rs1pub fn ser_catalog_source(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::CatalogSource,
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.output_schemas {
19 let mut array_3 = object.key("OutputSchemas").start_array();
20 for item_4 in var_2 {
21 {
22 #[allow(unused_mut)]
23 let mut object_5 = array_3.value().start_object();
24 crate::protocol_serde::shape_glue_schema::ser_glue_schema(&mut object_5, item_4)?;
25 object_5.finish();
26 }
27 }
28 array_3.finish();
29 }
30 Ok(())
31}
32
33pub(crate) fn de_catalog_source<'a, I>(
34 tokens: &mut ::std::iter::Peekable<I>,
35 _value: &'a [u8],
36) -> ::std::result::Result<Option<crate::types::CatalogSource>, ::aws_smithy_json::deserialize::error::DeserializeError>
37where
38 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
39{
40 match tokens.next().transpose()? {
41 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
42 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
43 #[allow(unused_mut)]
44 let mut builder = crate::types::builders::CatalogSourceBuilder::default();
45 loop {
46 match tokens.next().transpose()? {
47 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
48 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
49 "Name" => {
50 builder = builder.set_name(
51 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
53 .transpose()?,
54 );
55 }
56 "Database" => {
57 builder = builder.set_database(
58 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60 .transpose()?,
61 );
62 }
63 "Table" => {
64 builder = builder.set_table(
65 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
66 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
67 .transpose()?,
68 );
69 }
70 "PartitionPredicate" => {
71 builder = builder.set_partition_predicate(
72 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
73 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
74 .transpose()?,
75 );
76 }
77 "OutputSchemas" => {
78 builder = builder.set_output_schemas(crate::protocol_serde::shape_glue_schemas::de_glue_schemas(tokens, _value)?);
79 }
80 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
81 },
82 other => {
83 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
84 "expected object key or end object, found: {other:?}"
85 )))
86 }
87 }
88 }
89 Ok(Some(crate::serde_util::catalog_source_correct_errors(builder).build().map_err(
90 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
91 )?))
92 }
93 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
94 "expected start object or null",
95 )),
96 }
97}