aws_sdk_sagemaker/protocol_serde/
shape_processing_input.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_processing_input(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::ProcessingInput,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.input_name {
7        object.key("InputName").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.app_managed {
10        object.key("AppManaged").boolean(*var_2);
11    }
12    if let Some(var_3) = &input.s3_input {
13        #[allow(unused_mut)]
14        let mut object_4 = object.key("S3Input").start_object();
15        crate::protocol_serde::shape_processing_s3_input::ser_processing_s3_input(&mut object_4, var_3)?;
16        object_4.finish();
17    }
18    if let Some(var_5) = &input.dataset_definition {
19        #[allow(unused_mut)]
20        let mut object_6 = object.key("DatasetDefinition").start_object();
21        crate::protocol_serde::shape_dataset_definition::ser_dataset_definition(&mut object_6, var_5)?;
22        object_6.finish();
23    }
24    Ok(())
25}
26
27pub(crate) fn de_processing_input<'a, I>(
28    tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::ProcessingInput>, ::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::ProcessingInputBuilder::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                        "InputName" => {
43                            builder = builder.set_input_name(
44                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
46                                    .transpose()?,
47                            );
48                        }
49                        "AppManaged" => {
50                            builder = builder.set_app_managed(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
51                        }
52                        "S3Input" => {
53                            builder = builder.set_s3_input(crate::protocol_serde::shape_processing_s3_input::de_processing_s3_input(tokens)?);
54                        }
55                        "DatasetDefinition" => {
56                            builder = builder.set_dataset_definition(crate::protocol_serde::shape_dataset_definition::de_dataset_definition(tokens)?);
57                        }
58                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
59                    },
60                    other => {
61                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
62                            "expected object key or end object, found: {:?}",
63                            other
64                        )))
65                    }
66                }
67            }
68            Ok(Some(crate::serde_util::processing_input_correct_errors(builder).build()))
69        }
70        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
71            "expected start object or null",
72        )),
73    }
74}