aws_sdk_sagemaker/protocol_serde/
shape_labeling_job_data_source.rs1pub fn ser_labeling_job_data_source(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::LabelingJobDataSource,
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_labeling_job_s3_data_source::ser_labeling_job_s3_data_source(&mut object_2, var_1)?;
10 object_2.finish();
11 }
12 if let Some(var_3) = &input.sns_data_source {
13 #[allow(unused_mut)]
14 let mut object_4 = object.key("SnsDataSource").start_object();
15 crate::protocol_serde::shape_labeling_job_sns_data_source::ser_labeling_job_sns_data_source(&mut object_4, var_3)?;
16 object_4.finish();
17 }
18 Ok(())
19}
20
21pub(crate) fn de_labeling_job_data_source<'a, I>(
22 tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::LabelingJobDataSource>, ::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::LabelingJobDataSourceBuilder::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(
38 crate::protocol_serde::shape_labeling_job_s3_data_source::de_labeling_job_s3_data_source(tokens)?,
39 );
40 }
41 "SnsDataSource" => {
42 builder = builder.set_sns_data_source(
43 crate::protocol_serde::shape_labeling_job_sns_data_source::de_labeling_job_sns_data_source(tokens)?,
44 );
45 }
46 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
47 },
48 other => {
49 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
50 "expected object key or end object, found: {:?}",
51 other
52 )))
53 }
54 }
55 }
56 Ok(Some(builder.build()))
57 }
58 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
59 "expected start object or null",
60 )),
61 }
62}