aws_sdk_sagemaker/protocol_serde/
shape_custom_file_system.rs1pub fn ser_custom_file_system(
3 object_16: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::CustomFileSystem,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 match input {
7 crate::types::CustomFileSystem::EfsFileSystem(inner) => {
8 #[allow(unused_mut)]
9 let mut object_1 = object_16.key("EFSFileSystem").start_object();
10 crate::protocol_serde::shape_efs_file_system::ser_efs_file_system(&mut object_1, inner)?;
11 object_1.finish();
12 }
13 crate::types::CustomFileSystem::FSxLustreFileSystem(inner) => {
14 #[allow(unused_mut)]
15 let mut object_2 = object_16.key("FSxLustreFileSystem").start_object();
16 crate::protocol_serde::shape_f_sx_lustre_file_system::ser_f_sx_lustre_file_system(&mut object_2, inner)?;
17 object_2.finish();
18 }
19 crate::types::CustomFileSystem::Unknown => {
20 return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
21 "CustomFileSystem",
22 ))
23 }
24 }
25 Ok(())
26}
27
28pub(crate) fn de_custom_file_system<'a, I>(
29 tokens: &mut ::std::iter::Peekable<I>,
30) -> ::std::result::Result<Option<crate::types::CustomFileSystem>, ::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 "EFSFileSystem" => Some(crate::types::CustomFileSystem::EfsFileSystem(
59 crate::protocol_serde::shape_efs_file_system::de_efs_file_system(tokens)?.ok_or_else(|| {
60 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'EFSFileSystem' cannot be null")
61 })?,
62 )),
63 "FSxLustreFileSystem" => Some(crate::types::CustomFileSystem::FSxLustreFileSystem(
64 crate::protocol_serde::shape_f_sx_lustre_file_system::de_f_sx_lustre_file_system(tokens)?.ok_or_else(|| {
65 ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'FSxLustreFileSystem' cannot be null")
66 })?,
67 )),
68 _ => {
69 ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
70 Some(crate::types::CustomFileSystem::Unknown)
71 }
72 };
73 }
74 other => {
75 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
76 "expected object key or end object, found: {:?}",
77 other
78 )))
79 }
80 }
81 },
82 _ => {
83 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
84 "expected start object or null",
85 ))
86 }
87 }
88 if variant.is_none() {
89 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
90 "Union did not contain a valid variant.",
91 ));
92 }
93 Ok(variant)
94}