pub fn ser_clarify_shap_config(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::ClarifyShapConfig,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
if let Some(var_1) = &input.shap_baseline_config {
#[allow(unused_mut)]
let mut object_2 = object.key("ShapBaselineConfig").start_object();
crate::protocol_serde::shape_clarify_shap_baseline_config::ser_clarify_shap_baseline_config(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.number_of_samples {
object.key("NumberOfSamples").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_3).into()),
);
}
if let Some(var_4) = &input.use_logit {
object.key("UseLogit").boolean(*var_4);
}
if let Some(var_5) = &input.seed {
object.key("Seed").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_5).into()),
);
}
if let Some(var_6) = &input.text_config {
#[allow(unused_mut)]
let mut object_7 = object.key("TextConfig").start_object();
crate::protocol_serde::shape_clarify_text_config::ser_clarify_text_config(&mut object_7, var_6)?;
object_7.finish();
}
Ok(())
}
pub(crate) fn de_clarify_shap_config<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::ClarifyShapConfig>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::types::builders::ClarifyShapConfigBuilder::default();
loop {
match tokens.next().transpose()? {
Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
"ShapBaselineConfig" => {
builder = builder.set_shap_baseline_config(
crate::protocol_serde::shape_clarify_shap_baseline_config::de_clarify_shap_baseline_config(tokens)?,
);
}
"NumberOfSamples" => {
builder = builder.set_number_of_samples(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"UseLogit" => {
builder = builder.set_use_logit(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
}
"Seed" => {
builder = builder.set_seed(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"TextConfig" => {
builder = builder.set_text_config(crate::protocol_serde::shape_clarify_text_config::de_clarify_text_config(tokens)?);
}
_ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
},
other => {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
"expected object key or end object, found: {:?}",
other
)))
}
}
}
Ok(Some(crate::serde_util::clarify_shap_config_correct_errors(builder).build()))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}