aws_sdk_appstream/protocol_serde/
shape_user_stack_association.rs1pub fn ser_user_stack_association(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::UserStackAssociation,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 if let Some(var_1) = &input.stack_name {
7 object.key("StackName").string(var_1.as_str());
8 }
9 if let Some(var_2) = &input.user_name {
10 object.key("UserName").string(var_2.as_str());
11 }
12 if let Some(var_3) = &input.authentication_type {
13 object.key("AuthenticationType").string(var_3.as_str());
14 }
15 if let Some(var_4) = &input.send_email_notification {
16 object.key("SendEmailNotification").boolean(*var_4);
17 }
18 Ok(())
19}
20
21pub(crate) fn de_user_stack_association<'a, I>(
22 tokens: &mut ::std::iter::Peekable<I>,
23) -> ::std::result::Result<Option<crate::types::UserStackAssociation>, ::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::UserStackAssociationBuilder::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 "StackName" => {
37 builder = builder.set_stack_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 "UserName" => {
44 builder = builder.set_user_name(
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 "AuthenticationType" => {
51 builder = builder.set_authentication_type(
52 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
53 .map(|s| s.to_unescaped().map(|u| crate::types::AuthenticationType::from(u.as_ref())))
54 .transpose()?,
55 );
56 }
57 "SendEmailNotification" => {
58 builder = builder.set_send_email_notification(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
59 }
60 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
61 },
62 other => {
63 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
64 "expected object key or end object, found: {:?}",
65 other
66 )))
67 }
68 }
69 }
70 Ok(Some(crate::serde_util::user_stack_association_correct_errors(builder).build()))
71 }
72 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
73 "expected start object or null",
74 )),
75 }
76}