aws_sdk_config/protocol_serde/
shape_aggregate_resource_identifier.rs1pub fn ser_aggregate_resource_identifier(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::AggregateResourceIdentifier,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("SourceAccountId").string(input.source_account_id.as_str());
8 }
9 {
10 object.key("SourceRegion").string(input.source_region.as_str());
11 }
12 {
13 object.key("ResourceId").string(input.resource_id.as_str());
14 }
15 {
16 object.key("ResourceType").string(input.resource_type.as_str());
17 }
18 if let Some(var_1) = &input.resource_name {
19 object.key("ResourceName").string(var_1.as_str());
20 }
21 Ok(())
22}
23
24pub(crate) fn de_aggregate_resource_identifier<'a, I>(
25 tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::AggregateResourceIdentifier>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33 #[allow(unused_mut)]
34 let mut builder = crate::types::builders::AggregateResourceIdentifierBuilder::default();
35 loop {
36 match tokens.next().transpose()? {
37 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39 "SourceAccountId" => {
40 builder = builder.set_source_account_id(
41 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43 .transpose()?,
44 );
45 }
46 "SourceRegion" => {
47 builder = builder.set_source_region(
48 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
49 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
50 .transpose()?,
51 );
52 }
53 "ResourceId" => {
54 builder = builder.set_resource_id(
55 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
56 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
57 .transpose()?,
58 );
59 }
60 "ResourceType" => {
61 builder = builder.set_resource_type(
62 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
63 .map(|s| s.to_unescaped().map(|u| crate::types::ResourceType::from(u.as_ref())))
64 .transpose()?,
65 );
66 }
67 "ResourceName" => {
68 builder = builder.set_resource_name(
69 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
70 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
71 .transpose()?,
72 );
73 }
74 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
75 },
76 other => {
77 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
78 "expected object key or end object, found: {other:?}"
79 )))
80 }
81 }
82 }
83 Ok(Some(
84 crate::serde_util::aggregate_resource_identifier_correct_errors(builder)
85 .build()
86 .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
87 ))
88 }
89 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
90 "expected start object or null",
91 )),
92 }
93}