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