aws_sdk_ec2/protocol_serde/
shape_get_capacity_reservation_usage.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_capacity_reservation_usage_http_error(
4    _response_status: u16,
5    _response_headers: &::aws_smithy_runtime_api::http::Headers,
6    _response_body: &[u8],
7) -> std::result::Result<
8    crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageOutput,
9    crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageError,
10> {
11    #[allow(unused_mut)]
12    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
13        .map_err(crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    Err(crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageError::generic(generic))
17}
18
19#[allow(clippy::unnecessary_wraps)]
20pub fn de_get_capacity_reservation_usage_http_response(
21    _response_status: u16,
22    _response_headers: &::aws_smithy_runtime_api::http::Headers,
23    _response_body: &[u8],
24) -> std::result::Result<
25    crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageOutput,
26    crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageError,
27> {
28    Ok({
29        #[allow(unused_mut)]
30        let mut output = crate::operation::get_capacity_reservation_usage::builders::GetCapacityReservationUsageOutputBuilder::default();
31        output = crate::protocol_serde::shape_get_capacity_reservation_usage::de_get_capacity_reservation_usage(_response_body, output)
32            .map_err(crate::operation::get_capacity_reservation_usage::GetCapacityReservationUsageError::unhandled)?;
33        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
34        output.build()
35    })
36}
37
38#[allow(unused_mut)]
39pub fn de_get_capacity_reservation_usage(
40    inp: &[u8],
41    mut builder: crate::operation::get_capacity_reservation_usage::builders::GetCapacityReservationUsageOutputBuilder,
42) -> std::result::Result<
43    crate::operation::get_capacity_reservation_usage::builders::GetCapacityReservationUsageOutputBuilder,
44    ::aws_smithy_xml::decode::XmlDecodeError,
45> {
46    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
47
48    #[allow(unused_mut)]
49    let mut decoder = doc.root_element()?;
50    #[allow(unused_variables)]
51    let start_el = decoder.start_el();
52    if !(start_el.matches("GetCapacityReservationUsageResponse")) {
53        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
54            "invalid root, expected GetCapacityReservationUsageResponse got {:?}",
55            start_el
56        )));
57    }
58    while let Some(mut tag) = decoder.next_tag() {
59        match tag.start_el() {
60            s if s.matches("nextToken") /* NextToken com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$NextToken */ =>  {
61                let var_1 =
62                    Some(
63                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
64                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
65                            .into()
66                        )
67                        ?
68                    )
69                ;
70                builder = builder.set_next_token(var_1);
71            }
72            ,
73            s if s.matches("capacityReservationId") /* CapacityReservationId com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$CapacityReservationId */ =>  {
74                let var_2 =
75                    Some(
76                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
77                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
78                            .into()
79                        )
80                        ?
81                    )
82                ;
83                builder = builder.set_capacity_reservation_id(var_2);
84            }
85            ,
86            s if s.matches("instanceType") /* InstanceType com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$InstanceType */ =>  {
87                let var_3 =
88                    Some(
89                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
90                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
91                            .into()
92                        )
93                        ?
94                    )
95                ;
96                builder = builder.set_instance_type(var_3);
97            }
98            ,
99            s if s.matches("totalInstanceCount") /* TotalInstanceCount com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$TotalInstanceCount */ =>  {
100                let var_4 =
101                    Some(
102                         {
103                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
104                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
105                            )
106                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
107                        }
108                        ?
109                    )
110                ;
111                builder = builder.set_total_instance_count(var_4);
112            }
113            ,
114            s if s.matches("availableInstanceCount") /* AvailableInstanceCount com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$AvailableInstanceCount */ =>  {
115                let var_5 =
116                    Some(
117                         {
118                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
119                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
120                            )
121                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
122                        }
123                        ?
124                    )
125                ;
126                builder = builder.set_available_instance_count(var_5);
127            }
128            ,
129            s if s.matches("state") /* State com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$State */ =>  {
130                let var_6 =
131                    Some(
132                        Result::<crate::types::CapacityReservationState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
133                            crate::types::CapacityReservationState::from(
134                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
135                            )
136                        )
137                        ?
138                    )
139                ;
140                builder = builder.set_state(var_6);
141            }
142            ,
143            s if s.matches("instanceUsageSet") /* InstanceUsages com.amazonaws.ec2.synthetic#GetCapacityReservationUsageOutput$InstanceUsages */ =>  {
144                let var_7 =
145                    Some(
146                        crate::protocol_serde::shape_instance_usage_set::de_instance_usage_set(&mut tag)
147                        ?
148                    )
149                ;
150                builder = builder.set_instance_usages(var_7);
151            }
152            ,
153            _ => {}
154        }
155    }
156    Ok(builder)
157}