aws_sdk_sagemaker/protocol_serde/
shape_data_source.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_data_source(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::DataSource,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.s3_data_source {
7        #[allow(unused_mut)]
8        let mut object_2 = object.key("S3DataSource").start_object();
9        crate::protocol_serde::shape_s3_data_source::ser_s3_data_source(&mut object_2, var_1)?;
10        object_2.finish();
11    }
12    if let Some(var_3) = &input.file_system_data_source {
13        #[allow(unused_mut)]
14        let mut object_4 = object.key("FileSystemDataSource").start_object();
15        crate::protocol_serde::shape_file_system_data_source::ser_file_system_data_source(&mut object_4, var_3)?;
16        object_4.finish();
17    }
18    Ok(())
19}
20
21pub(crate) fn de_data_source<'a, I>(
22    tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::DataSource>, ::aws_smithy_json::deserialize::error::DeserializeError>
24where
25    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
26{
27    match tokens.next().transpose()? {
28        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
29        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
30            #[allow(unused_mut)]
31            let mut builder = crate::types::builders::DataSourceBuilder::default();
32            loop {
33                match tokens.next().transpose()? {
34                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
35                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
36                        "S3DataSource" => {
37                            builder = builder.set_s3_data_source(crate::protocol_serde::shape_s3_data_source::de_s3_data_source(tokens)?);
38                        }
39                        "FileSystemDataSource" => {
40                            builder = builder.set_file_system_data_source(
41                                crate::protocol_serde::shape_file_system_data_source::de_file_system_data_source(tokens)?,
42                            );
43                        }
44                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
45                    },
46                    other => {
47                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
48                            "expected object key or end object, found: {:?}",
49                            other
50                        )))
51                    }
52                }
53            }
54            Ok(Some(builder.build()))
55        }
56        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
57            "expected start object or null",
58        )),
59    }
60}