aws_sdk_fms/protocol_serde/
shape_app.rs1pub fn ser_app(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::App,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("AppName").string(input.app_name.as_str());
8 }
9 {
10 object.key("Protocol").string(input.protocol.as_str());
11 }
12 {
13 object.key("Port").number(
14 #[allow(clippy::useless_conversion)]
15 ::aws_smithy_types::Number::NegInt((input.port).into()),
16 );
17 }
18 Ok(())
19}
20
21pub(crate) fn de_app<'a, I>(
22 tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::App>, ::aws_smithy_json::deserialize::error::DeserializeError>
24where
25 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
26{
27 match tokens.next().transpose()? {
28 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
29 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
30 #[allow(unused_mut)]
31 let mut builder = crate::types::builders::AppBuilder::default();
32 loop {
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
35 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
36 "AppName" => {
37 builder = builder.set_app_name(
38 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
39 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
40 .transpose()?,
41 );
42 }
43 "Protocol" => {
44 builder = builder.set_protocol(
45 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
46 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
47 .transpose()?,
48 );
49 }
50 "Port" => {
51 builder = builder.set_port(
52 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
53 .map(i64::try_from)
54 .transpose()?,
55 );
56 }
57 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
58 },
59 other => {
60 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
61 "expected object key or end object, found: {other:?}"
62 )))
63 }
64 }
65 }
66 Ok(Some(crate::serde_util::app_correct_errors(builder).build().map_err(|err| {
67 ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err)
68 })?))
69 }
70 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
71 "expected start object or null",
72 )),
73 }
74}