aws_sdk_ec2/protocol_serde/
shape_security_group_rule.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_security_group_rule(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::SecurityGroupRule, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::SecurityGroupRule::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("securityGroupRuleId") /* SecurityGroupRuleId com.amazonaws.ec2#SecurityGroupRule$SecurityGroupRuleId */ =>  {
11                let var_1 =
12                    Some(
13                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
14                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
15                            .into()
16                        )
17                        ?
18                    )
19                ;
20                builder = builder.set_security_group_rule_id(var_1);
21            }
22            ,
23            s if s.matches("groupId") /* GroupId com.amazonaws.ec2#SecurityGroupRule$GroupId */ =>  {
24                let var_2 =
25                    Some(
26                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
27                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
28                            .into()
29                        )
30                        ?
31                    )
32                ;
33                builder = builder.set_group_id(var_2);
34            }
35            ,
36            s if s.matches("groupOwnerId") /* GroupOwnerId com.amazonaws.ec2#SecurityGroupRule$GroupOwnerId */ =>  {
37                let var_3 =
38                    Some(
39                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
40                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
41                            .into()
42                        )
43                        ?
44                    )
45                ;
46                builder = builder.set_group_owner_id(var_3);
47            }
48            ,
49            s if s.matches("isEgress") /* IsEgress com.amazonaws.ec2#SecurityGroupRule$IsEgress */ =>  {
50                let var_4 =
51                    Some(
52                         {
53                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
54                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
55                            )
56                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
57                        }
58                        ?
59                    )
60                ;
61                builder = builder.set_is_egress(var_4);
62            }
63            ,
64            s if s.matches("ipProtocol") /* IpProtocol com.amazonaws.ec2#SecurityGroupRule$IpProtocol */ =>  {
65                let var_5 =
66                    Some(
67                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
68                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
69                            .into()
70                        )
71                        ?
72                    )
73                ;
74                builder = builder.set_ip_protocol(var_5);
75            }
76            ,
77            s if s.matches("fromPort") /* FromPort com.amazonaws.ec2#SecurityGroupRule$FromPort */ =>  {
78                let var_6 =
79                    Some(
80                         {
81                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
82                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
83                            )
84                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
85                        }
86                        ?
87                    )
88                ;
89                builder = builder.set_from_port(var_6);
90            }
91            ,
92            s if s.matches("toPort") /* ToPort com.amazonaws.ec2#SecurityGroupRule$ToPort */ =>  {
93                let var_7 =
94                    Some(
95                         {
96                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
97                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
98                            )
99                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
100                        }
101                        ?
102                    )
103                ;
104                builder = builder.set_to_port(var_7);
105            }
106            ,
107            s if s.matches("cidrIpv4") /* CidrIpv4 com.amazonaws.ec2#SecurityGroupRule$CidrIpv4 */ =>  {
108                let var_8 =
109                    Some(
110                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
111                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
112                            .into()
113                        )
114                        ?
115                    )
116                ;
117                builder = builder.set_cidr_ipv4(var_8);
118            }
119            ,
120            s if s.matches("cidrIpv6") /* CidrIpv6 com.amazonaws.ec2#SecurityGroupRule$CidrIpv6 */ =>  {
121                let var_9 =
122                    Some(
123                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
124                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
125                            .into()
126                        )
127                        ?
128                    )
129                ;
130                builder = builder.set_cidr_ipv6(var_9);
131            }
132            ,
133            s if s.matches("prefixListId") /* PrefixListId com.amazonaws.ec2#SecurityGroupRule$PrefixListId */ =>  {
134                let var_10 =
135                    Some(
136                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
137                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
138                            .into()
139                        )
140                        ?
141                    )
142                ;
143                builder = builder.set_prefix_list_id(var_10);
144            }
145            ,
146            s if s.matches("referencedGroupInfo") /* ReferencedGroupInfo com.amazonaws.ec2#SecurityGroupRule$ReferencedGroupInfo */ =>  {
147                let var_11 =
148                    Some(
149                        crate::protocol_serde::shape_referenced_security_group::de_referenced_security_group(&mut tag)
150                        ?
151                    )
152                ;
153                builder = builder.set_referenced_group_info(var_11);
154            }
155            ,
156            s if s.matches("description") /* Description com.amazonaws.ec2#SecurityGroupRule$Description */ =>  {
157                let var_12 =
158                    Some(
159                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
160                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
161                            .into()
162                        )
163                        ?
164                    )
165                ;
166                builder = builder.set_description(var_12);
167            }
168            ,
169            s if s.matches("tagSet") /* Tags com.amazonaws.ec2#SecurityGroupRule$Tags */ =>  {
170                let var_13 =
171                    Some(
172                        crate::protocol_serde::shape_tag_list::de_tag_list(&mut tag)
173                        ?
174                    )
175                ;
176                builder = builder.set_tags(var_13);
177            }
178            ,
179            s if s.matches("securityGroupRuleArn") /* SecurityGroupRuleArn com.amazonaws.ec2#SecurityGroupRule$SecurityGroupRuleArn */ =>  {
180                let var_14 =
181                    Some(
182                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
183                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
184                            .into()
185                        )
186                        ?
187                    )
188                ;
189                builder = builder.set_security_group_rule_arn(var_14);
190            }
191            ,
192            _ => {}
193        }
194    }
195    Ok(builder.build())
196}