aws_sdk_sagemaker/protocol_serde/
shape_custom_file_system_config.rs1pub fn ser_custom_file_system_config(
3 object_18: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::CustomFileSystemConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 match input {
7 crate::types::CustomFileSystemConfig::EfsFileSystemConfig(inner) => {
8 #[allow(unused_mut)]
9 let mut object_1 = object_18.key("EFSFileSystemConfig").start_object();
10 crate::protocol_serde::shape_efs_file_system_config::ser_efs_file_system_config(&mut object_1, inner)?;
11 object_1.finish();
12 }
13 crate::types::CustomFileSystemConfig::FSxLustreFileSystemConfig(inner) => {
14 #[allow(unused_mut)]
15 let mut object_2 = object_18.key("FSxLustreFileSystemConfig").start_object();
16 crate::protocol_serde::shape_f_sx_lustre_file_system_config::ser_f_sx_lustre_file_system_config(&mut object_2, inner)?;
17 object_2.finish();
18 }
19 crate::types::CustomFileSystemConfig::Unknown => {
20 return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
21 "CustomFileSystemConfig",
22 ))
23 }
24 }
25 Ok(())
26}
27
28pub(crate) fn de_custom_file_system_config<'a, I>(
29 tokens: &mut ::std::iter::Peekable<I>,
30) -> ::std::result::Result<Option<crate::types::CustomFileSystemConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
31where
32 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
33{
34 let mut variant = None;
35 match tokens.next().transpose()? {
36 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
37 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => loop {
38 match tokens.next().transpose()? {
39 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
40 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
41 if let ::std::option::Option::Some(::std::result::Result::Ok(::aws_smithy_json::deserialize::Token::ValueNull { .. })) =
42 tokens.peek()
43 {
44 let _ = tokens.next().expect("peek returned a token")?;
45 continue;
46 }
47 let key = key.to_unescaped()?;
48 if key == "__type" {
49 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
50 continue;
51 }
52 if variant.is_some() {
53 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
54 "encountered mixed variants in union",
55 ));
56 }
57 variant = match key.as_ref() {
58 "EFSFileSystemConfig" => Some(crate::types::CustomFileSystemConfig::EfsFileSystemConfig(
59 crate::protocol_serde::shape_efs_file_system_config::de_efs_file_system_config(tokens)?.ok_or_else(|| {
60 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'EFSFileSystemConfig' cannot be null")
61 })?,
62 )),
63 "FSxLustreFileSystemConfig" => Some(crate::types::CustomFileSystemConfig::FSxLustreFileSystemConfig(
64 crate::protocol_serde::shape_f_sx_lustre_file_system_config::de_f_sx_lustre_file_system_config(tokens)?.ok_or_else(
65 || {
66 ::aws_smithy_json::deserialize::error::DeserializeError::custom(
67 "value for 'FSxLustreFileSystemConfig' cannot be null",
68 )
69 },
70 )?,
71 )),
72 _ => {
73 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
74 Some(crate::types::CustomFileSystemConfig::Unknown)
75 }
76 };
77 }
78 other => {
79 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
80 "expected object key or end object, found: {:?}",
81 other
82 )))
83 }
84 }
85 },
86 _ => {
87 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
88 "expected start object or null",
89 ))
90 }
91 }
92 if variant.is_none() {
93 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
94 "Union did not contain a valid variant.",
95 ));
96 }
97 Ok(variant)
98}