aws_sdk_sagemaker/protocol_serde/
shape_async_inference_output_config.rs1pub fn ser_async_inference_output_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::AsyncInferenceOutputConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.kms_key_id {
7 object.key("KmsKeyId").string(var_1.as_str());
8 }
9 if let Some(var_2) = &input.s3_output_path {
10 object.key("S3OutputPath").string(var_2.as_str());
11 }
12 if let Some(var_3) = &input.notification_config {
13 #[allow(unused_mut)]
14 let mut object_4 = object.key("NotificationConfig").start_object();
15 crate::protocol_serde::shape_async_inference_notification_config::ser_async_inference_notification_config(&mut object_4, var_3)?;
16 object_4.finish();
17 }
18 if let Some(var_5) = &input.s3_failure_path {
19 object.key("S3FailurePath").string(var_5.as_str());
20 }
21 Ok(())
22}
23
24pub(crate) fn de_async_inference_output_config<'a, I>(
25 tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::AsyncInferenceOutputConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33 #[allow(unused_mut)]
34 let mut builder = crate::types::builders::AsyncInferenceOutputConfigBuilder::default();
35 loop {
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39 "KmsKeyId" => {
40 builder = builder.set_kms_key_id(
41 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43 .transpose()?,
44 );
45 }
46 "S3OutputPath" => {
47 builder = builder.set_s3_output_path(
48 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
50 .transpose()?,
51 );
52 }
53 "NotificationConfig" => {
54 builder = builder.set_notification_config(
55 crate::protocol_serde::shape_async_inference_notification_config::de_async_inference_notification_config(tokens)?,
56 );
57 }
58 "S3FailurePath" => {
59 builder = builder.set_s3_failure_path(
60 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
61 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
62 .transpose()?,
63 );
64 }
65 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
66 },
67 other => {
68 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
69 "expected object key or end object, found: {:?}",
70 other
71 )))
72 }
73 }
74 }
75 Ok(Some(builder.build()))
76 }
77 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
78 "expected start object or null",
79 )),
80 }
81}