aws_sdk_appsync/protocol_serde/
shape_api_cache.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub(crate) fn de_api_cache<'a, I>(
3    tokens: &mut ::std::iter::Peekable<I>,
4) -> ::std::result::Result<Option<crate::types::ApiCache>, ::aws_smithy_json::deserialize::error::DeserializeError>
5where
6    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
7{
8    match tokens.next().transpose()? {
9        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
10        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
11            #[allow(unused_mut)]
12            let mut builder = crate::types::builders::ApiCacheBuilder::default();
13            loop {
14                match tokens.next().transpose()? {
15                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
16                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
17                        "ttl" => {
18                            builder = builder.set_ttl(
19                                ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
20                                    .map(i64::try_from)
21                                    .transpose()?,
22                            );
23                        }
24                        "apiCachingBehavior" => {
25                            builder = builder.set_api_caching_behavior(
26                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
27                                    .map(|s| s.to_unescaped().map(|u| crate::types::ApiCachingBehavior::from(u.as_ref())))
28                                    .transpose()?,
29                            );
30                        }
31                        "transitEncryptionEnabled" => {
32                            builder =
33                                builder.set_transit_encryption_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
34                        }
35                        "atRestEncryptionEnabled" => {
36                            builder =
37                                builder.set_at_rest_encryption_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
38                        }
39                        "type" => {
40                            builder = builder.set_type(
41                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42                                    .map(|s| s.to_unescaped().map(|u| crate::types::ApiCacheType::from(u.as_ref())))
43                                    .transpose()?,
44                            );
45                        }
46                        "status" => {
47                            builder = builder.set_status(
48                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49                                    .map(|s| s.to_unescaped().map(|u| crate::types::ApiCacheStatus::from(u.as_ref())))
50                                    .transpose()?,
51                            );
52                        }
53                        "healthMetricsConfig" => {
54                            builder = builder.set_health_metrics_config(
55                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56                                    .map(|s| s.to_unescaped().map(|u| crate::types::CacheHealthMetricsConfig::from(u.as_ref())))
57                                    .transpose()?,
58                            );
59                        }
60                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
61                    },
62                    other => {
63                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
64                            "expected object key or end object, found: {:?}",
65                            other
66                        )))
67                    }
68                }
69            }
70            Ok(Some(builder.build()))
71        }
72        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
73            "expected start object or null",
74        )),
75    }
76}