pub(crate) fn de_location_action<'a, I>(
tokens: &mut ::std::iter::Peekable<I>,
) -> Result<Option<crate::types::LocationAction>, ::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::LocationActionBuilder::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() {
"roleArn" => {
builder = builder.set_role_arn(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"trackerName" => {
builder = builder.set_tracker_name(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"deviceId" => {
builder = builder.set_device_id(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"timestamp" => {
builder = builder.set_timestamp(crate::protocol_serde::shape_location_timestamp::de_location_timestamp(tokens)?);
}
"latitude" => {
builder = builder.set_latitude(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"longitude" => {
builder = builder.set_longitude(
::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => ::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::location_action_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",
)),
}
}
pub fn ser_location_action(
object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::types::LocationAction,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
{
object.key("roleArn").string(input.role_arn.as_str());
}
{
object.key("trackerName").string(input.tracker_name.as_str());
}
{
object.key("deviceId").string(input.device_id.as_str());
}
if let Some(var_1) = &input.timestamp {
#[allow(unused_mut)]
let mut object_2 = object.key("timestamp").start_object();
crate::protocol_serde::shape_location_timestamp::ser_location_timestamp(&mut object_2, var_1)?;
object_2.finish();
}
{
object.key("latitude").string(input.latitude.as_str());
}
{
object.key("longitude").string(input.longitude.as_str());
}
Ok(())
}