aws_sdk_ec2/protocol_serde/
shape_purchase.rs1#[allow(clippy::needless_question_mark)]
3pub fn de_purchase(
4 decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::Purchase, ::aws_smithy_xml::decode::XmlDecodeError> {
6 #[allow(unused_mut)]
7 let mut builder = crate::types::Purchase::builder();
8 while let Some(mut tag) = decoder.next_tag() {
9 match tag.start_el() {
10 s if s.matches("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("duration") => {
25 let var_2 =
26 Some(
27 {
28 <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
29 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
30 )
31 .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
32 }
33 ?
34 )
35 ;
36 builder = builder.set_duration(var_2);
37 }
38 ,
39 s if s.matches("hostIdSet") => {
40 let var_3 =
41 Some(
42 crate::protocol_serde::shape_response_host_id_set::de_response_host_id_set(&mut tag)
43 ?
44 )
45 ;
46 builder = builder.set_host_id_set(var_3);
47 }
48 ,
49 s if s.matches("hostReservationId") => {
50 let var_4 =
51 Some(
52 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
53 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
54 .into()
55 )
56 ?
57 )
58 ;
59 builder = builder.set_host_reservation_id(var_4);
60 }
61 ,
62 s if s.matches("hourlyPrice") => {
63 let var_5 =
64 Some(
65 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
66 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
67 .into()
68 )
69 ?
70 )
71 ;
72 builder = builder.set_hourly_price(var_5);
73 }
74 ,
75 s if s.matches("instanceFamily") => {
76 let var_6 =
77 Some(
78 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
79 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
80 .into()
81 )
82 ?
83 )
84 ;
85 builder = builder.set_instance_family(var_6);
86 }
87 ,
88 s if s.matches("paymentOption") => {
89 let var_7 =
90 Some(
91 Result::<crate::types::PaymentOption, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
92 crate::types::PaymentOption::from(
93 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
94 )
95 )
96 ?
97 )
98 ;
99 builder = builder.set_payment_option(var_7);
100 }
101 ,
102 s if s.matches("upfrontPrice") => {
103 let var_8 =
104 Some(
105 Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
106 ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
107 .into()
108 )
109 ?
110 )
111 ;
112 builder = builder.set_upfront_price(var_8);
113 }
114 ,
115 _ => {}
116 }
117 }
118 Ok(builder.build())
119}