aws_sdk_apprunner/protocol_serde/
shape_code_repository.rs1pub fn ser_code_repository(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::CodeRepository,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("RepositoryUrl").string(input.repository_url.as_str());
8 }
9 if let Some(var_1) = &input.source_code_version {
10 #[allow(unused_mut)]
11 let mut object_2 = object.key("SourceCodeVersion").start_object();
12 crate::protocol_serde::shape_source_code_version::ser_source_code_version(&mut object_2, var_1)?;
13 object_2.finish();
14 }
15 if let Some(var_3) = &input.code_configuration {
16 #[allow(unused_mut)]
17 let mut object_4 = object.key("CodeConfiguration").start_object();
18 crate::protocol_serde::shape_code_configuration::ser_code_configuration(&mut object_4, var_3)?;
19 object_4.finish();
20 }
21 if let Some(var_5) = &input.source_directory {
22 object.key("SourceDirectory").string(var_5.as_str());
23 }
24 Ok(())
25}
26
27pub(crate) fn de_code_repository<'a, I>(
28 tokens: &mut ::std::iter::Peekable<I>,
29) -> ::std::result::Result<Option<crate::types::CodeRepository>, ::aws_smithy_json::deserialize::error::DeserializeError>
30where
31 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
32{
33 match tokens.next().transpose()? {
34 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
35 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
36 #[allow(unused_mut)]
37 let mut builder = crate::types::builders::CodeRepositoryBuilder::default();
38 loop {
39 match tokens.next().transpose()? {
40 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
41 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
42 "RepositoryUrl" => {
43 builder = builder.set_repository_url(
44 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
45 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
46 .transpose()?,
47 );
48 }
49 "SourceCodeVersion" => {
50 builder =
51 builder.set_source_code_version(crate::protocol_serde::shape_source_code_version::de_source_code_version(tokens)?);
52 }
53 "CodeConfiguration" => {
54 builder = builder.set_code_configuration(crate::protocol_serde::shape_code_configuration::de_code_configuration(tokens)?);
55 }
56 "SourceDirectory" => {
57 builder = builder.set_source_directory(
58 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
59 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
60 .transpose()?,
61 );
62 }
63 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
64 },
65 other => {
66 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
67 "expected object key or end object, found: {:?}",
68 other
69 )))
70 }
71 }
72 }
73 Ok(Some(crate::serde_util::code_repository_correct_errors(builder).build().map_err(
74 |err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err),
75 )?))
76 }
77 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
78 "expected start object or null",
79 )),
80 }
81}