aws_sdk_sagemaker/protocol_serde/
shape_online_store_config.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_online_store_config(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::OnlineStoreConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.security_config {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("SecurityConfig").start_object();
9        crate::protocol_serde::shape_online_store_security_config::ser_online_store_security_config(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.enable_online_store {
13        object.key("EnableOnlineStore").boolean(*var_3);
14    }
15    if let Some(var_4) = &input.ttl_duration {
16        #[allow(unused_mut)]
17        let mut object_5 = object.key("TtlDuration").start_object();
18        crate::protocol_serde::shape_ttl_duration::ser_ttl_duration(&mut object_5, var_4)?;
19        object_5.finish();
20    }
21    if let Some(var_6) = &input.storage_type {
22        object.key("StorageType").string(var_6.as_str());
23    }
24    Ok(())
25}
26
27pub(crate) fn de_online_store_config<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::OnlineStoreConfig>, ::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::OnlineStoreConfigBuilder::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                        "SecurityConfig" => {
43                            builder = builder.set_security_config(
44                                crate::protocol_serde::shape_online_store_security_config::de_online_store_security_config(tokens)?,
45                            );
46                        }
47                        "EnableOnlineStore" => {
48                            builder = builder.set_enable_online_store(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
49                        }
50                        "TtlDuration" => {
51                            builder = builder.set_ttl_duration(crate::protocol_serde::shape_ttl_duration::de_ttl_duration(tokens)?);
52                        }
53                        "StorageType" => {
54                            builder = builder.set_storage_type(
55                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56                                    .map(|s| s.to_unescaped().map(|u| crate::types::StorageType::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}