aws_sdk_s3/protocol_serde/
shape_cors_rule.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::needless_question_mark)]
pub fn de_cors_rule(
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
) -> Result<crate::types::CorsRule, ::aws_smithy_xml::decode::XmlDecodeError> {
    #[allow(unused_mut)]
    let mut builder = crate::types::CorsRule::builder();
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("ID") /* ID com.amazonaws.s3#CORSRule$ID */ =>  {
                let var_1 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_id(var_1);
            }
            ,
            s if s.matches("AllowedHeader") /* AllowedHeaders com.amazonaws.s3#CORSRule$AllowedHeaders */ =>  {
                let var_2 =
                    Some(
                        Result::<::std::vec::Vec::<::std::string::String>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
                            let mut list_3 = builder.allowed_headers.take().unwrap_or_default();
                            list_3.push(
                                Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                                    ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                                    .into()
                                )
                                ?
                            );
                            list_3
                        })
                        ?
                    )
                ;
                builder = builder.set_allowed_headers(var_2);
            }
            ,
            s if s.matches("AllowedMethod") /* AllowedMethods com.amazonaws.s3#CORSRule$AllowedMethods */ =>  {
                let var_4 =
                    Some(
                        Result::<::std::vec::Vec::<::std::string::String>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
                            let mut list_5 = builder.allowed_methods.take().unwrap_or_default();
                            list_5.push(
                                Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                                    ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                                    .into()
                                )
                                ?
                            );
                            list_5
                        })
                        ?
                    )
                ;
                builder = builder.set_allowed_methods(var_4);
            }
            ,
            s if s.matches("AllowedOrigin") /* AllowedOrigins com.amazonaws.s3#CORSRule$AllowedOrigins */ =>  {
                let var_6 =
                    Some(
                        Result::<::std::vec::Vec::<::std::string::String>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
                            let mut list_7 = builder.allowed_origins.take().unwrap_or_default();
                            list_7.push(
                                Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                                    ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                                    .into()
                                )
                                ?
                            );
                            list_7
                        })
                        ?
                    )
                ;
                builder = builder.set_allowed_origins(var_6);
            }
            ,
            s if s.matches("ExposeHeader") /* ExposeHeaders com.amazonaws.s3#CORSRule$ExposeHeaders */ =>  {
                let var_8 =
                    Some(
                        Result::<::std::vec::Vec::<::std::string::String>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
                            let mut list_9 = builder.expose_headers.take().unwrap_or_default();
                            list_9.push(
                                Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                                    ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                                    .into()
                                )
                                ?
                            );
                            list_9
                        })
                        ?
                    )
                ;
                builder = builder.set_expose_headers(var_8);
            }
            ,
            s if s.matches("MaxAgeSeconds") /* MaxAgeSeconds com.amazonaws.s3#CORSRule$MaxAgeSeconds */ =>  {
                let var_10 =
                    Some(
                         {
                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.s3#MaxAgeSeconds`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_max_age_seconds(var_10);
            }
            ,
            _ => {}
        }
    }
    Ok(crate::serde_util::cors_rule_correct_errors(builder)
        .build()
        .map_err(|_| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing field"))?)
}

pub fn ser_cors_rule(
    input: &crate::types::CorsRule,
    writer: ::aws_smithy_xml::encode::ElWriter,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    #[allow(unused_mut)]
    let mut scope = writer.finish();
    if let Some(var_11) = &input.id {
        let mut inner_writer = scope.start_el("ID").finish();
        inner_writer.data(var_11.as_str());
    }
    if let Some(var_12) = &input.allowed_headers {
        for list_item_13 in var_12 {
            {
                let mut inner_writer = scope.start_el("AllowedHeader").finish();
                inner_writer.data(list_item_13.as_str());
            }
        }
    }
    {
        for list_item_14 in &input.allowed_methods {
            {
                let mut inner_writer = scope.start_el("AllowedMethod").finish();
                inner_writer.data(list_item_14.as_str());
            }
        }
    }
    {
        for list_item_15 in &input.allowed_origins {
            {
                let mut inner_writer = scope.start_el("AllowedOrigin").finish();
                inner_writer.data(list_item_15.as_str());
            }
        }
    }
    if let Some(var_16) = &input.expose_headers {
        for list_item_17 in var_16 {
            {
                let mut inner_writer = scope.start_el("ExposeHeader").finish();
                inner_writer.data(list_item_17.as_str());
            }
        }
    }
    if let Some(var_18) = &input.max_age_seconds {
        let mut inner_writer = scope.start_el("MaxAgeSeconds").finish();
        inner_writer.data(::aws_smithy_types::primitive::Encoder::from(*var_18).encode());
    }
    scope.finish();
    Ok(())
}