aws_sdk_appsync/protocol_serde/
shape_caching_config.rs1pub fn ser_caching_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::CachingConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("ttl").number(
8 #[allow(clippy::useless_conversion)]
9 ::aws_smithy_types::Number::NegInt((input.ttl).into()),
10 );
11 }
12 if let Some(var_1) = &input.caching_keys {
13 let mut array_2 = object.key("cachingKeys").start_array();
14 for item_3 in var_1 {
15 {
16 array_2.value().string(item_3.as_str());
17 }
18 }
19 array_2.finish();
20 }
21 Ok(())
22}
23
24pub(crate) fn de_caching_config<'a, I>(
25 tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::CachingConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33 #[allow(unused_mut)]
34 let mut builder = crate::types::builders::CachingConfigBuilder::default();
35 loop {
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39 "ttl" => {
40 builder = builder.set_ttl(
41 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
42 .map(i64::try_from)
43 .transpose()?,
44 );
45 }
46 "cachingKeys" => {
47 builder = builder.set_caching_keys(crate::protocol_serde::shape_caching_keys::de_caching_keys(tokens)?);
48 }
49 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
50 },
51 other => {
52 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
53 "expected object key or end object, found: {:?}",
54 other
55 )))
56 }
57 }
58 }
59 Ok(Some(crate::serde_util::caching_config_correct_errors(builder).build()))
60 }
61 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
62 "expected start object or null",
63 )),
64 }
65}