pub fn ser_auto_adjust_data(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::AutoAdjustData,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("AutoAdjustType").string(input.auto_adjust_type.as_str());
}
if let Some(var_1) = &input.historical_options {
#[allow(unused_mut)]
let mut object_2 = object.key("HistoricalOptions").start_object();
crate::protocol_serde::shape_historical_options::ser_historical_options(&mut object_2, var_1)?;
object_2.finish();
}
if let Some(var_3) = &input.last_auto_adjust_time {
object
.key("LastAutoAdjustTime")
.date_time(var_3, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
}
Ok(())
}
pub(crate) fn de_auto_adjust_data<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
_value: &'a [u8],
depth: u32,
) -> ::std::result::Result<Option<crate::types::AutoAdjustData>, ::aws_smithy_json::deserialize::error::DeserializeError>
where
I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
{
if depth >= 128u32 {
return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"maximum nesting depth exceeded",
));
}
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::AutoAdjustDataBuilder::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() {
"AutoAdjustType" => {
builder = builder.set_auto_adjust_type(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| crate::types::AutoAdjustType::from(u.as_ref())))
.transpose()?,
);
}
"HistoricalOptions" => {
builder = builder.set_historical_options(crate::protocol_serde::shape_historical_options::de_historical_options(
tokens,
_value,
depth + 1,
)?);
}
"LastAutoAdjustTime" => {
builder = builder.set_last_auto_adjust_time(::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
tokens.next(),
::aws_smithy_types::date_time::Format::EpochSeconds,
)?);
}
_ => ::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::auto_adjust_data_correct_errors(builder).build().map_err(
|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
)?))
}
_ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
"expected start object or null",
)),
}
}