aws_sdk_imagebuilder/protocol_serde/
shape_fast_launch_configuration.rs1pub fn ser_fast_launch_configuration(
3 object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4 input: &crate::types::FastLaunchConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6 {
7 object.key("enabled").boolean(input.enabled);
8 }
9 if let Some(var_1) = &input.snapshot_configuration {
10 #[allow(unused_mut)]
11 let mut object_2 = object.key("snapshotConfiguration").start_object();
12 crate::protocol_serde::shape_fast_launch_snapshot_configuration::ser_fast_launch_snapshot_configuration(&mut object_2, var_1)?;
13 object_2.finish();
14 }
15 if let Some(var_3) = &input.max_parallel_launches {
16 object.key("maxParallelLaunches").number(
17 #[allow(clippy::useless_conversion)]
18 ::aws_smithy_types::Number::NegInt((*var_3).into()),
19 );
20 }
21 if let Some(var_4) = &input.launch_template {
22 #[allow(unused_mut)]
23 let mut object_5 = object.key("launchTemplate").start_object();
24 crate::protocol_serde::shape_fast_launch_launch_template_specification::ser_fast_launch_launch_template_specification(&mut object_5, var_4)?;
25 object_5.finish();
26 }
27 if let Some(var_6) = &input.account_id {
28 object.key("accountId").string(var_6.as_str());
29 }
30 Ok(())
31}
32
33pub(crate) fn de_fast_launch_configuration<'a, I>(
34 tokens: &mut ::std::iter::Peekable<I>,
35) -> ::std::result::Result<Option<crate::types::FastLaunchConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
36where
37 I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
38{
39 match tokens.next().transpose()? {
40 Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
41 Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
42 #[allow(unused_mut)]
43 let mut builder = crate::types::builders::FastLaunchConfigurationBuilder::default();
44 loop {
45 match tokens.next().transpose()? {
46 Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
47 Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
48 match key.to_unescaped()?.as_ref() {
49 "enabled" => {
50 builder = builder.set_enabled(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
51 }
52 "snapshotConfiguration" => {
53 builder = builder.set_snapshot_configuration(
54 crate::protocol_serde::shape_fast_launch_snapshot_configuration::de_fast_launch_snapshot_configuration(tokens)?,
55 );
56 }
57 "maxParallelLaunches" => {
58 builder = builder.set_max_parallel_launches(
59 ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
60 .map(i32::try_from)
61 .transpose()?,
62 );
63 }
64 "launchTemplate" => {
65 builder = builder.set_launch_template(
66 crate::protocol_serde::shape_fast_launch_launch_template_specification::de_fast_launch_launch_template_specification(tokens)?
67 );
68 }
69 "accountId" => {
70 builder = builder.set_account_id(
71 ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
72 .map(|s| s.to_unescaped().map(|u| u.into_owned()))
73 .transpose()?,
74 );
75 }
76 _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
77 }
78 }
79 other => {
80 return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
81 "expected object key or end object, found: {:?}",
82 other
83 )))
84 }
85 }
86 }
87 Ok(Some(crate::serde_util::fast_launch_configuration_correct_errors(builder).build()))
88 }
89 _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
90 "expected start object or null",
91 )),
92 }
93}