aws_sdk_codepipeline/protocol_serde/
shape_pipeline_variable_declaration.rs1pub fn ser_pipeline_variable_declaration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::PipelineVariableDeclaration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("name").string(input.name.as_str());
8 }
9 if let Some(var_1) = &input.default_value {
10 object.key("defaultValue").string(var_1.as_str());
11 }
12 if let Some(var_2) = &input.description {
13 object.key("description").string(var_2.as_str());
14 }
15 Ok(())
16}
17
18pub(crate) fn de_pipeline_variable_declaration<'a, I>(
19 tokens: &mut ::std::iter::Peekable<I>,
20) -> ::std::result::Result<Option<crate::types::PipelineVariableDeclaration>, ::aws_smithy_json::deserialize::error::DeserializeError>
21where
22 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
23{
24 match tokens.next().transpose()? {
25 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
26 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
27 #[allow(unused_mut)]
28 let mut builder = crate::types::builders::PipelineVariableDeclarationBuilder::default();
29 loop {
30 match tokens.next().transpose()? {
31 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
32 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
33 "name" => {
34 builder = builder.set_name(
35 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
36 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
37 .transpose()?,
38 );
39 }
40 "defaultValue" => {
41 builder = builder.set_default_value(
42 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
43 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
44 .transpose()?,
45 );
46 }
47 "description" => {
48 builder = builder.set_description(
49 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
50 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
51 .transpose()?,
52 );
53 }
54 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
55 },
56 other => {
57 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
58 "expected object key or end object, found: {:?}",
59 other
60 )))
61 }
62 }
63 }
64 Ok(Some(
65 crate::serde_util::pipeline_variable_declaration_correct_errors(builder)
66 .build()
67 .map_err(|err| ::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}