aws_sdk_appsync/protocol_serde/
shape_dynamodb_data_source_config.rs1pub fn ser_dynamodb_data_source_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::DynamodbDataSourceConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("tableName").string(input.table_name.as_str());
8 }
9 {
10 object.key("awsRegion").string(input.aws_region.as_str());
11 }
12 if input.use_caller_credentials {
13 object.key("useCallerCredentials").boolean(input.use_caller_credentials);
14 }
15 if let Some(var_1) = &input.delta_sync_config {
16 #[allow(unused_mut)]
17 let mut object_2 = object.key("deltaSyncConfig").start_object();
18 crate::protocol_serde::shape_delta_sync_config::ser_delta_sync_config(&mut object_2, var_1)?;
19 object_2.finish();
20 }
21 if input.versioned {
22 object.key("versioned").boolean(input.versioned);
23 }
24 Ok(())
25}
26
27pub(crate) fn de_dynamodb_data_source_config<'a, I>(
28 tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::DynamodbDataSourceConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36 #[allow(unused_mut)]
37 let mut builder = crate::types::builders::DynamodbDataSourceConfigBuilder::default();
38 loop {
39 match tokens.next().transpose()? {
40 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42 "tableName" => {
43 builder = builder.set_table_name(
44 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
46 .transpose()?,
47 );
48 }
49 "awsRegion" => {
50 builder = builder.set_aws_region(
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 "useCallerCredentials" => {
57 builder = builder.set_use_caller_credentials(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
58 }
59 "deltaSyncConfig" => {
60 builder = builder.set_delta_sync_config(crate::protocol_serde::shape_delta_sync_config::de_delta_sync_config(tokens)?);
61 }
62 "versioned" => {
63 builder = builder.set_versioned(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
64 }
65 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
66 },
67 other => {
68 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
69 "expected object key or end object, found: {:?}",
70 other
71 )))
72 }
73 }
74 }
75 Ok(Some(
76 crate::serde_util::dynamodb_data_source_config_correct_errors(builder)
77 .build()
78 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
79 ))
80 }
81 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
82 "expected start object or null",
83 )),
84 }
85}