1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | pub fn ser_service_managed_ebs_volume_configuration(
|
3 - | object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
|
4 - | input: &crate::types::ServiceManagedEbsVolumeConfiguration,
|
5 - | ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
|
6 - | if let Some(var_1) = &input.encrypted {
|
7 - | object.key("encrypted").boolean(*var_1);
|
8 - | }
|
9 - | if let Some(var_2) = &input.kms_key_id {
|
10 - | object.key("kmsKeyId").string(var_2.as_str());
|
11 - | }
|
12 - | if let Some(var_3) = &input.volume_type {
|
13 - | object.key("volumeType").string(var_3.as_str());
|
14 - | }
|
15 - | if let Some(var_4) = &input.size_in_gib {
|
16 - | object.key("sizeInGiB").number(
|
17 - | #[allow(clippy::useless_conversion)]
|
18 - | ::aws_smithy_types::Number::NegInt((*var_4).into()),
|
19 - | );
|
20 - | }
|
21 - | if let Some(var_5) = &input.snapshot_id {
|
22 - | object.key("snapshotId").string(var_5.as_str());
|
23 - | }
|
24 - | if let Some(var_6) = &input.volume_initialization_rate {
|
25 - | object.key("volumeInitializationRate").number(
|
26 - | #[allow(clippy::useless_conversion)]
|
27 - | ::aws_smithy_types::Number::NegInt((*var_6).into()),
|
28 - | );
|
29 - | }
|
30 - | if let Some(var_7) = &input.iops {
|
31 - | object.key("iops").number(
|
32 - | #[allow(clippy::useless_conversion)]
|
33 - | ::aws_smithy_types::Number::NegInt((*var_7).into()),
|
34 - | );
|
35 - | }
|
36 - | if let Some(var_8) = &input.throughput {
|
37 - | object.key("throughput").number(
|
38 - | #[allow(clippy::useless_conversion)]
|
39 - | ::aws_smithy_types::Number::NegInt((*var_8).into()),
|
40 - | );
|
41 - | }
|
42 - | if let Some(var_9) = &input.tag_specifications {
|
43 - | let mut array_10 = object.key("tagSpecifications").start_array();
|
44 - | for item_11 in var_9 {
|
45 - | {
|
46 - | #[allow(unused_mut)]
|
47 - | let mut object_12 = array_10.value().start_object();
|
48 - | crate::protocol_serde::shape_ebs_tag_specification::ser_ebs_tag_specification(&mut object_12, item_11)?;
|
49 - | object_12.finish();
|
50 - | }
|
51 - | }
|
52 - | array_10.finish();
|
53 - | }
|
54 - | {
|
55 - | object.key("roleArn").string(input.role_arn.as_str());
|
56 - | }
|
57 - | if let Some(var_13) = &input.filesystem_type {
|
58 - | object.key("filesystemType").string(var_13.as_str());
|
59 - | }
|
60 - | Ok(())
|
61 - | }
|
62 - |
|
63 - | pub(crate) fn de_service_managed_ebs_volume_configuration<'a, I>(
|
64 - | tokens: &mut ::std::iter::Peekable<I>,
|
65 - | _value: &'a [u8],
|
66 - | ) -> ::std::result::Result<Option<crate::types::ServiceManagedEbsVolumeConfiguration>, ::aws_smithy_json::deserialize::error::DeserializeError>
|
67 - | where
|
68 - | I: Iterator<Item = Result<::aws_smithy_json::deserialize::Token<'a>, ::aws_smithy_json::deserialize::error::DeserializeError>>,
|
69 - | {
|
70 - | match tokens.next().transpose()? {
|
71 - | Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
|
72 - | Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
|
73 - | #[allow(unused_mut)]
|
74 - | let mut builder = crate::types::builders::ServiceManagedEbsVolumeConfigurationBuilder::default();
|
75 - | loop {
|
76 - | match tokens.next().transpose()? {
|
77 - | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
78 - | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
|
79 - | "encrypted" => {
|
80 - | builder = builder.set_encrypted(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
|
81 - | }
|
82 - | "kmsKeyId" => {
|
83 - | builder = builder.set_kms_key_id(
|
84 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
85 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
86 - | .transpose()?,
|
87 - | );
|
88 - | }
|
89 - | "volumeType" => {
|
90 - | builder = builder.set_volume_type(
|
91 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
92 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
93 - | .transpose()?,
|
94 - | );
|
95 - | }
|
96 - | "sizeInGiB" => {
|
97 - | builder = builder.set_size_in_gib(
|
98 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
99 - | .map(i32::try_from)
|
100 - | .transpose()?,
|
101 - | );
|
102 - | }
|
103 - | "snapshotId" => {
|
104 - | builder = builder.set_snapshot_id(
|
105 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
106 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
107 - | .transpose()?,
|
108 - | );
|
109 - | }
|
110 - | "volumeInitializationRate" => {
|
111 - | builder = builder.set_volume_initialization_rate(
|
112 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
113 - | .map(i32::try_from)
|
114 - | .transpose()?,
|
115 - | );
|
116 - | }
|
117 - | "iops" => {
|
118 - | builder = builder.set_iops(
|
119 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
120 - | .map(i32::try_from)
|
121 - | .transpose()?,
|
122 - | );
|
123 - | }
|
124 - | "throughput" => {
|
125 - | builder = builder.set_throughput(
|
126 - | ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
|
127 - | .map(i32::try_from)
|
128 - | .transpose()?,
|
129 - | );
|
130 - | }
|
131 - | "tagSpecifications" => {
|
132 - | builder = builder.set_tag_specifications(crate::protocol_serde::shape_ebs_tag_specifications::de_ebs_tag_specifications(
|
133 - | tokens, _value,
|
134 - | )?);
|
135 - | }
|
136 - | "roleArn" => {
|
137 - | builder = builder.set_role_arn(
|
138 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
139 - | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
140 - | .transpose()?,
|
141 - | );
|
142 - | }
|
143 - | "filesystemType" => {
|
144 - | builder = builder.set_filesystem_type(
|
145 - | ::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
|
146 - | .map(|s| s.to_unescaped().map(|u| crate::types::TaskFilesystemType::from(u.as_ref())))
|
147 - | .transpose()?,
|
148 - | );
|
149 - | }
|
150 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
151 - | },
|
152 - | other => {
|
153 - | return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
154 - | "expected object key or end object, found: {other:?}"
|
155 - | )))
|
156 - | }
|
157 - | }
|
158 - | }
|
159 - | Ok(Some(
|
160 - | crate::serde_util::service_managed_ebs_volume_configuration_correct_errors(builder)
|
161 - | .build()
|
162 - | .map_err(|err| ::aws_smithy_json::deserialize::error::DeserializeError::custom_source("Response was invalid", err))?,
|
163 - | ))
|
164 - | }
|
165 - | _ => Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
166 - | "expected start object or null",
|
167 - | )),
|
168 - | }
|
169 - | }
|