aws_sdk_iot/protocol_serde/
shape_location_action.rs1pub(crate) fn de_location_action<'a, I>(
3 tokens: &mut ::std::iter::Peekable<I>,
4 _value: &'a [u8],
5) -> ::std::result::Result<Option<crate::types::LocationAction>, ::aws_smithy_json::deserialize::error::DeserializeError>
6where
7 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
8{
9 match tokens.next().transpose()? {
10 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
11 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
12 #[allow(unused_mut)]
13 let mut builder = crate::types::builders::LocationActionBuilder::default();
14 loop {
15 match tokens.next().transpose()? {
16 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
17 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
18 "roleArn" => {
19 builder = builder.set_role_arn(
20 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
21 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
22 .transpose()?,
23 );
24 }
25 "trackerName" => {
26 builder = builder.set_tracker_name(
27 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
28 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
29 .transpose()?,
30 );
31 }
32 "deviceId" => {
33 builder = builder.set_device_id(
34 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
35 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
36 .transpose()?,
37 );
38 }
39 "timestamp" => {
40 builder = builder.set_timestamp(crate::protocol_serde::shape_location_timestamp::de_location_timestamp(tokens, _value)?);
41 }
42 "latitude" => {
43 builder = builder.set_latitude(
44 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
46 .transpose()?,
47 );
48 }
49 "longitude" => {
50 builder = builder.set_longitude(
51 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
52 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
53 .transpose()?,
54 );
55 }
56 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
57 },
58 other => {
59 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
60 "expected object key or end object, found: {other:?}"
61 )))
62 }
63 }
64 }
65 Ok(Some(crate::serde_util::location_action_correct_errors(builder).build().map_err(
66 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
67 )?))
68 }
69 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
70 "expected start object or null",
71 )),
72 }
73}
74
75pub fn ser_location_action(
76 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
77 input: &crate::types::LocationAction,
78) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
79 {
80 object.key("roleArn").string(input.role_arn.as_str());
81 }
82 {
83 object.key("trackerName").string(input.tracker_name.as_str());
84 }
85 {
86 object.key("deviceId").string(input.device_id.as_str());
87 }
88 if let Some(var_1) = &input.timestamp {
89 #[allow(unused_mut)]
90 let mut object_2 = object.key("timestamp").start_object();
91 crate::protocol_serde::shape_location_timestamp::ser_location_timestamp(&mut object_2, var_1)?;
92 object_2.finish();
93 }
94 {
95 object.key("latitude").string(input.latitude.as_str());
96 }
97 {
98 object.key("longitude").string(input.longitude.as_str());
99 }
100 Ok(())
101}