aws_sdk_sagemaker/protocol_serde/
shape_clarify_shap_config.rs1pub fn ser_clarify_shap_config(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::ClarifyShapConfig,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.shap_baseline_config {
7 #[allow(unused_mut)]
8 let mut object_2 = object.key("ShapBaselineConfig").start_object();
9 crate::protocol_serde::shape_clarify_shap_baseline_config::ser_clarify_shap_baseline_config(&mut object_2, var_1)?;
10 object_2.finish();
11 }
12 if let Some(var_3) = &input.number_of_samples {
13 object.key("NumberOfSamples").number(
14 #[allow(clippy::useless_conversion)]
15 ::aws_smithy_types::Number::NegInt((*var_3).into()),
16 );
17 }
18 if let Some(var_4) = &input.use_logit {
19 object.key("UseLogit").boolean(*var_4);
20 }
21 if let Some(var_5) = &input.seed {
22 object.key("Seed").number(
23 #[allow(clippy::useless_conversion)]
24 ::aws_smithy_types::Number::NegInt((*var_5).into()),
25 );
26 }
27 if let Some(var_6) = &input.text_config {
28 #[allow(unused_mut)]
29 let mut object_7 = object.key("TextConfig").start_object();
30 crate::protocol_serde::shape_clarify_text_config::ser_clarify_text_config(&mut object_7, var_6)?;
31 object_7.finish();
32 }
33 Ok(())
34}
35
36pub(crate) fn de_clarify_shap_config<'a, I>(
37 tokens: &mut ::std::iter::Peekable<I>,
38) -> ::std::result::Result<Option<crate::types::ClarifyShapConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
39where
40 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
41{
42 match tokens.next().transpose()? {
43 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
44 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
45 #[allow(unused_mut)]
46 let mut builder = crate::types::builders::ClarifyShapConfigBuilder::default();
47 loop {
48 match tokens.next().transpose()? {
49 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
50 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
51 "ShapBaselineConfig" => {
52 builder = builder.set_shap_baseline_config(
53 crate::protocol_serde::shape_clarify_shap_baseline_config::de_clarify_shap_baseline_config(tokens)?,
54 );
55 }
56 "NumberOfSamples" => {
57 builder = builder.set_number_of_samples(
58 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
59 .map(i32::try_from)
60 .transpose()?,
61 );
62 }
63 "UseLogit" => {
64 builder = builder.set_use_logit(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
65 }
66 "Seed" => {
67 builder = builder.set_seed(
68 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
69 .map(i32::try_from)
70 .transpose()?,
71 );
72 }
73 "TextConfig" => {
74 builder = builder.set_text_config(crate::protocol_serde::shape_clarify_text_config::de_clarify_text_config(tokens)?);
75 }
76 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
77 },
78 other => {
79 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
80 "expected object key or end object, found: {:?}",
81 other
82 )))
83 }
84 }
85 }
86 Ok(Some(crate::serde_util::clarify_shap_config_correct_errors(builder).build()))
87 }
88 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
89 "expected start object or null",
90 )),
91 }
92}