pub fn ser_audio_normalization_settings(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::AudioNormalizationSettings,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
if let Some(var_1) = &input.algorithm {
object.key("algorithm").string(var_1.as_str());
}
if let Some(var_2) = &input.algorithm_control {
object.key("algorithmControl").string(var_2.as_str());
}
if let Some(var_3) = &input.correction_gate_level {
object.key("correctionGateLevel").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::NegInt((*var_3).into()),
);
}
if let Some(var_4) = &input.loudness_logging {
object.key("loudnessLogging").string(var_4.as_str());
}
if let Some(var_5) = &input.peak_calculation {
object.key("peakCalculation").string(var_5.as_str());
}
if let Some(var_6) = &input.target_lkfs {
object.key("targetLkfs").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::Float((*var_6).into()),
);
}
if let Some(var_7) = &input.true_peak_limiter_threshold {
object.key("truePeakLimiterThreshold").number(
#[allow(clippy::useless_conversion)]
::aws_smithy_types::Number::Float((*var_7).into()),
);
}
Ok(())
}
pub(crate) fn de_audio_normalization_settings<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> ::std::result::Result<Option<crate::types::AudioNormalizationSettings>, ::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::AudioNormalizationSettingsBuilder::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() {
"algorithm" => {
builder = builder.set_algorithm(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| crate::types::AudioNormalizationAlgorithm::from(u.as_ref())))
.transpose()?,
);
}
"algorithmControl" => {
builder = builder.set_algorithm_control(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| {
s.to_unescaped()
.map(|u| crate::types::AudioNormalizationAlgorithmControl::from(u.as_ref()))
})
.transpose()?,
);
}
"correctionGateLevel" => {
builder = builder.set_correction_gate_level(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
.map(i32::try_from)
.transpose()?,
);
}
"loudnessLogging" => {
builder = builder.set_loudness_logging(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| {
s.to_unescaped()
.map(|u| crate::types::AudioNormalizationLoudnessLogging::from(u.as_ref()))
})
.transpose()?,
);
}
"peakCalculation" => {
builder = builder.set_peak_calculation(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| {
s.to_unescaped()
.map(|u| crate::types::AudioNormalizationPeakCalculation::from(u.as_ref()))
})
.transpose()?,
);
}
"targetLkfs" => {
builder = builder.set_target_lkfs(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy()),
);
}
"truePeakLimiterThreshold" => {
builder = builder.set_true_peak_limiter_threshold(
::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?.map(|v| v.to_f64_lossy()),
);
}
_ => ::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(builder.build()))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}