aws_sdk_codepipeline/protocol_serde/
shape_git_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_git_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::GitConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    {
7        object.key("sourceActionName").string(input.source_action_name.as_str());
8    }
9    if let Some(var_1) = &input.push {
10        let mut array_2 = object.key("push").start_array();
11        for item_3 in var_1 {
12            {
13                #[allow(unused_mut)]
14                let mut object_4 = array_2.value().start_object();
15                crate::protocol_serde::shape_git_push_filter::ser_git_push_filter(&mut object_4, item_3)?;
16                object_4.finish();
17            }
18        }
19        array_2.finish();
20    }
21    if let Some(var_5) = &input.pull_request {
22        let mut array_6 = object.key("pullRequest").start_array();
23        for item_7 in var_5 {
24            {
25                #[allow(unused_mut)]
26                let mut object_8 = array_6.value().start_object();
27                crate::protocol_serde::shape_git_pull_request_filter::ser_git_pull_request_filter(&mut object_8, item_7)?;
28                object_8.finish();
29            }
30        }
31        array_6.finish();
32    }
33    Ok(())
34}
35
36pub(crate) fn de_git_configuration<'a, I>(
37    tokens: &mut ::std::iter::Peekable<I>,
38) -> ::std::result::Result<Option<crate::types::GitConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
39where
40    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
41{
42    match tokens.next().transpose()? {
43        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
44        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
45            #[allow(unused_mut)]
46            let mut builder = crate::types::builders::GitConfigurationBuilder::default();
47            loop {
48                match tokens.next().transpose()? {
49                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
50                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
51                        "sourceActionName" => {
52                            builder = builder.set_source_action_name(
53                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
54                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
55                                    .transpose()?,
56                            );
57                        }
58                        "push" => {
59                            builder = builder.set_push(crate::protocol_serde::shape_git_push_filter_list::de_git_push_filter_list(tokens)?);
60                        }
61                        "pullRequest" => {
62                            builder = builder.set_pull_request(
63                                crate::protocol_serde::shape_git_pull_request_filter_list::de_git_pull_request_filter_list(tokens)?,
64                            );
65                        }
66                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
67                    },
68                    other => {
69                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
70                            "expected object key or end object, found: {:?}",
71                            other
72                        )))
73                    }
74                }
75            }
76            Ok(Some(crate::serde_util::git_configuration_correct_errors(builder).build().map_err(
77                |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
78            )?))
79        }
80        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
81            "expected start object or null",
82        )),
83    }
84}