Skip to main content

aws_sdk_s3/protocol_serde/
shape_redirect_all_requests_to.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_redirect_all_requests_to(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::RedirectAllRequestsTo, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::RedirectAllRequestsTo::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("HostName") /* HostName com.amazonaws.s3#RedirectAllRequestsTo$HostName */ =>  {
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_host_name(var_1);
21            }
22            ,
23            s if s.matches("Protocol") /* Protocol com.amazonaws.s3#RedirectAllRequestsTo$Protocol */ =>  {
24                let var_2 =
25                    Some(
26                        Result::<crate::types::Protocol, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
27                            crate::types::Protocol::from(
28                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
29                            )
30                        )
31                        ?
32                    )
33                ;
34                builder = builder.set_protocol(var_2);
35            }
36            ,
37            _ => {}
38        }
39    }
40    Ok(crate::serde_util::redirect_all_requests_to_correct_errors(builder)
41        .build()
42        .map_err(|_| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing field"))?)
43}
44
45pub fn ser_redirect_all_requests_to(
46    input: &crate::types::RedirectAllRequestsTo,
47    writer: ::aws_smithy_xml::encode::ElWriter,
48) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
49    #[allow(unused_mut)]
50    let mut scope = writer.finish();
51    {
52        let mut inner_writer = scope.start_el("HostName").finish();
53        inner_writer.data(input.host_name.as_str());
54    }
55    if let Some(var_3) = &input.protocol {
56        let mut inner_writer = scope.start_el("Protocol").finish();
57        inner_writer.data(var_3.as_str());
58    }
59    scope.finish();
60    Ok(())
61}