aws_sdk_imagebuilder/protocol_serde/
shape_instance_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_instance_configuration(
3    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
4    input: &crate::types::InstanceConfiguration,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    if let Some(var_1) = &input.image {
7        object.key("image").string(var_1.as_str());
8    }
9    if let Some(var_2) = &input.block_device_mappings {
10        let mut array_3 = object.key("blockDeviceMappings").start_array();
11        for item_4 in var_2 {
12            {
13                #[allow(unused_mut)]
14                let mut object_5 = array_3.value().start_object();
15                crate::protocol_serde::shape_instance_block_device_mapping::ser_instance_block_device_mapping(&mut object_5, item_4)?;
16                object_5.finish();
17            }
18        }
19        array_3.finish();
20    }
21    Ok(())
22}
23
24pub(crate) fn de_instance_configuration<'a, I>(
25    tokens: &mut ::std::iter::Peekable<I>,
26) -> ::std::result::Result<Option<crate::types::InstanceConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
27where
28    I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
29{
30    match tokens.next().transpose()? {
31        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
32        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
33            #[allow(unused_mut)]
34            let mut builder = crate::types::builders::InstanceConfigurationBuilder::default();
35            loop {
36                match tokens.next().transpose()? {
37                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
38                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
39                        "image" => {
40                            builder = builder.set_image(
41                                ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
42                                    .map(|s| s.to_unescaped().map(|u| u.into_owned()))
43                                    .transpose()?,
44                            );
45                        }
46                        "blockDeviceMappings" => {
47                            builder = builder.set_block_device_mappings(
48                                crate::protocol_serde::shape_instance_block_device_mappings::de_instance_block_device_mappings(tokens)?,
49                            );
50                        }
51                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
52                    },
53                    other => {
54                        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
55                            "expected object key or end object, found: {:?}",
56                            other
57                        )))
58                    }
59                }
60            }
61            Ok(Some(builder.build()))
62        }
63        _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
64            "expected start object or null",
65        )),
66    }
67}