aws_sdk_ec2/protocol_serde/
shape_instance_capacity.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_instance_capacity(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::InstanceCapacity, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::InstanceCapacity::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("availableCapacity") /* AvailableCapacity com.amazonaws.ec2#InstanceCapacity$AvailableCapacity */ =>  {
11                let var_1 =
12                    Some(
13                         {
14                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
15                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
16                            )
17                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
18                        }
19                        ?
20                    )
21                ;
22                builder = builder.set_available_capacity(var_1);
23            }
24            ,
25            s if s.matches("instanceType") /* InstanceType com.amazonaws.ec2#InstanceCapacity$InstanceType */ =>  {
26                let var_2 =
27                    Some(
28                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
29                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
30                            .into()
31                        )
32                        ?
33                    )
34                ;
35                builder = builder.set_instance_type(var_2);
36            }
37            ,
38            s if s.matches("totalCapacity") /* TotalCapacity com.amazonaws.ec2#InstanceCapacity$TotalCapacity */ =>  {
39                let var_3 =
40                    Some(
41                         {
42                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
43                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
44                            )
45                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
46                        }
47                        ?
48                    )
49                ;
50                builder = builder.set_total_capacity(var_3);
51            }
52            ,
53            _ => {}
54        }
55    }
56    Ok(builder.build())
57}