aws_sdk_ec2/protocol_serde/
shape_reserved_instances.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_reserved_instances(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::ReservedInstances, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::ReservedInstances::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("currencyCode") /* CurrencyCode com.amazonaws.ec2#ReservedInstances$CurrencyCode */ =>  {
11                let var_1 =
12                    Some(
13                        Result::<crate::types::CurrencyCodeValues, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
14                            crate::types::CurrencyCodeValues::from(
15                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
16                            )
17                        )
18                        ?
19                    )
20                ;
21                builder = builder.set_currency_code(var_1);
22            }
23            ,
24            s if s.matches("instanceTenancy") /* InstanceTenancy com.amazonaws.ec2#ReservedInstances$InstanceTenancy */ =>  {
25                let var_2 =
26                    Some(
27                        Result::<crate::types::Tenancy, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
28                            crate::types::Tenancy::from(
29                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
30                            )
31                        )
32                        ?
33                    )
34                ;
35                builder = builder.set_instance_tenancy(var_2);
36            }
37            ,
38            s if s.matches("offeringClass") /* OfferingClass com.amazonaws.ec2#ReservedInstances$OfferingClass */ =>  {
39                let var_3 =
40                    Some(
41                        Result::<crate::types::OfferingClassType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
42                            crate::types::OfferingClassType::from(
43                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
44                            )
45                        )
46                        ?
47                    )
48                ;
49                builder = builder.set_offering_class(var_3);
50            }
51            ,
52            s if s.matches("offeringType") /* OfferingType com.amazonaws.ec2#ReservedInstances$OfferingType */ =>  {
53                let var_4 =
54                    Some(
55                        Result::<crate::types::OfferingTypeValues, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
56                            crate::types::OfferingTypeValues::from(
57                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
58                            )
59                        )
60                        ?
61                    )
62                ;
63                builder = builder.set_offering_type(var_4);
64            }
65            ,
66            s if s.matches("recurringCharges") /* RecurringCharges com.amazonaws.ec2#ReservedInstances$RecurringCharges */ =>  {
67                let var_5 =
68                    Some(
69                        crate::protocol_serde::shape_recurring_charges_list::de_recurring_charges_list(&mut tag)
70                        ?
71                    )
72                ;
73                builder = builder.set_recurring_charges(var_5);
74            }
75            ,
76            s if s.matches("scope") /* Scope com.amazonaws.ec2#ReservedInstances$Scope */ =>  {
77                let var_6 =
78                    Some(
79                        Result::<crate::types::Scope, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
80                            crate::types::Scope::from(
81                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
82                            )
83                        )
84                        ?
85                    )
86                ;
87                builder = builder.set_scope(var_6);
88            }
89            ,
90            s if s.matches("tagSet") /* Tags com.amazonaws.ec2#ReservedInstances$Tags */ =>  {
91                let var_7 =
92                    Some(
93                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
94                        ?
95                    )
96                ;
97                builder = builder.set_tags(var_7);
98            }
99            ,
100            s if s.matches("availabilityZoneId") /* AvailabilityZoneId com.amazonaws.ec2#ReservedInstances$AvailabilityZoneId */ =>  {
101                let var_8 =
102                    Some(
103                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
104                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
105                            .into()
106                        )
107                        ?
108                    )
109                ;
110                builder = builder.set_availability_zone_id(var_8);
111            }
112            ,
113            s if s.matches("reservedInstancesId") /* ReservedInstancesId com.amazonaws.ec2#ReservedInstances$ReservedInstancesId */ =>  {
114                let var_9 =
115                    Some(
116                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
117                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
118                            .into()
119                        )
120                        ?
121                    )
122                ;
123                builder = builder.set_reserved_instances_id(var_9);
124            }
125            ,
126            s if s.matches("instanceType") /* InstanceType com.amazonaws.ec2#ReservedInstances$InstanceType */ =>  {
127                let var_10 =
128                    Some(
129                        Result::<crate::types::InstanceType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
130                            crate::types::InstanceType::from(
131                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
132                            )
133                        )
134                        ?
135                    )
136                ;
137                builder = builder.set_instance_type(var_10);
138            }
139            ,
140            s if s.matches("availabilityZone") /* AvailabilityZone com.amazonaws.ec2#ReservedInstances$AvailabilityZone */ =>  {
141                let var_11 =
142                    Some(
143                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
144                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
145                            .into()
146                        )
147                        ?
148                    )
149                ;
150                builder = builder.set_availability_zone(var_11);
151            }
152            ,
153            s if s.matches("start") /* Start com.amazonaws.ec2#ReservedInstances$Start */ =>  {
154                let var_12 =
155                    Some(
156                        ::aws_smithy_types::DateTime::from_str(
157                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
158                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
159                        )
160                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
161                        ?
162                    )
163                ;
164                builder = builder.set_start(var_12);
165            }
166            ,
167            s if s.matches("end") /* End com.amazonaws.ec2#ReservedInstances$End */ =>  {
168                let var_13 =
169                    Some(
170                        ::aws_smithy_types::DateTime::from_str(
171                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
172                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
173                        )
174                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
175                        ?
176                    )
177                ;
178                builder = builder.set_end(var_13);
179            }
180            ,
181            s if s.matches("duration") /* Duration com.amazonaws.ec2#ReservedInstances$Duration */ =>  {
182                let var_14 =
183                    Some(
184                         {
185                            <i64 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
186                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
187                            )
188                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (long: `com.amazonaws.ec2#Long`)"))
189                        }
190                        ?
191                    )
192                ;
193                builder = builder.set_duration(var_14);
194            }
195            ,
196            s if s.matches("usagePrice") /* UsagePrice com.amazonaws.ec2#ReservedInstances$UsagePrice */ =>  {
197                let var_15 =
198                    Some(
199                         {
200                            <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
201                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
202                            )
203                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (float: `com.amazonaws.ec2#Float`)"))
204                        }
205                        ?
206                    )
207                ;
208                builder = builder.set_usage_price(var_15);
209            }
210            ,
211            s if s.matches("fixedPrice") /* FixedPrice com.amazonaws.ec2#ReservedInstances$FixedPrice */ =>  {
212                let var_16 =
213                    Some(
214                         {
215                            <f32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
216                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
217                            )
218                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (float: `com.amazonaws.ec2#Float`)"))
219                        }
220                        ?
221                    )
222                ;
223                builder = builder.set_fixed_price(var_16);
224            }
225            ,
226            s if s.matches("instanceCount") /* InstanceCount com.amazonaws.ec2#ReservedInstances$InstanceCount */ =>  {
227                let var_17 =
228                    Some(
229                         {
230                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
231                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
232                            )
233                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
234                        }
235                        ?
236                    )
237                ;
238                builder = builder.set_instance_count(var_17);
239            }
240            ,
241            s if s.matches("productDescription") /* ProductDescription com.amazonaws.ec2#ReservedInstances$ProductDescription */ =>  {
242                let var_18 =
243                    Some(
244                        Result::<crate::types::RiProductDescription, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
245                            crate::types::RiProductDescription::from(
246                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
247                            )
248                        )
249                        ?
250                    )
251                ;
252                builder = builder.set_product_description(var_18);
253            }
254            ,
255            s if s.matches("state") /* State com.amazonaws.ec2#ReservedInstances$State */ =>  {
256                let var_19 =
257                    Some(
258                        Result::<crate::types::ReservedInstanceState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
259                            crate::types::ReservedInstanceState::from(
260                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
261                            )
262                        )
263                        ?
264                    )
265                ;
266                builder = builder.set_state(var_19);
267            }
268            ,
269            _ => {}
270        }
271    }
272    Ok(builder.build())
273}