aws_sdk_s3/protocol_serde/
shape_get_bucket_lifecycle_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_bucket_lifecycle_configuration_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_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationOutput,
9    crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError,
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_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError::unhandled)?;
14    generic_builder = crate::s3_request_id::apply_extended_request_id(generic_builder, _response_headers);
15    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
16    let generic = generic_builder.build();
17    Err(crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError::generic(generic))
18}
19
20#[allow(clippy::unnecessary_wraps)]
21pub fn de_get_bucket_lifecycle_configuration_http_response(
22    _response_status: u16,
23    _response_headers: &::aws_smithy_runtime_api::http::Headers,
24    _response_body: &[u8],
25) -> std::result::Result<
26    crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationOutput,
27    crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError,
28> {
29    Ok({
30        #[allow(unused_mut)]
31        let mut output = crate::operation::get_bucket_lifecycle_configuration::builders::GetBucketLifecycleConfigurationOutputBuilder::default();
32        output = crate::protocol_serde::shape_get_bucket_lifecycle_configuration::de_get_bucket_lifecycle_configuration(_response_body, output)
33            .map_err(crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError::unhandled)?;
34        output = output.set_transition_default_minimum_object_size(
35            crate::protocol_serde::shape_get_bucket_lifecycle_configuration_output::de_transition_default_minimum_object_size_header(
36                _response_headers,
37            )
38            .map_err(|_| {
39                crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationError::unhandled(
40                    "Failed to parse TransitionDefaultMinimumObjectSize from header `x-amz-transition-default-minimum-object-size",
41                )
42            })?,
43        );
44        output._set_extended_request_id(crate::s3_request_id::RequestIdExt::extended_request_id(_response_headers).map(str::to_string));
45        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
46        output.build()
47    })
48}
49
50pub fn ser_get_bucket_lifecycle_configuration_headers(
51    input: &crate::operation::get_bucket_lifecycle_configuration::GetBucketLifecycleConfigurationInput,
52    mut builder: ::http::request::Builder,
53) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
54    if let ::std::option::Option::Some(inner_1) = &input.expected_bucket_owner {
55        let formatted_2 = inner_1.as_str();
56        let header_value = formatted_2;
57        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
58            ::aws_smithy_types::error::operation::BuildError::invalid_field(
59                "expected_bucket_owner",
60                format!("`{}` cannot be used as a header value: {}", &header_value, err),
61            )
62        })?;
63        builder = builder.header("x-amz-expected-bucket-owner", header_value);
64    }
65    Ok(builder)
66}
67
68#[allow(unused_mut)]
69pub fn de_get_bucket_lifecycle_configuration(
70    inp: &[u8],
71    mut builder: crate::operation::get_bucket_lifecycle_configuration::builders::GetBucketLifecycleConfigurationOutputBuilder,
72) -> std::result::Result<
73    crate::operation::get_bucket_lifecycle_configuration::builders::GetBucketLifecycleConfigurationOutputBuilder,
74    ::aws_smithy_xml::decode::XmlDecodeError,
75> {
76    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
77
78    #[allow(unused_mut)]
79    let mut decoder = doc.root_element()?;
80    #[allow(unused_variables)]
81    let start_el = decoder.start_el();
82    if !start_el.matches("LifecycleConfiguration") {
83        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
84            "encountered invalid XML root: expected LifecycleConfiguration but got {:?}. This is likely a bug in the SDK.",
85            start_el
86        )));
87    }
88    while let Some(mut tag) = decoder.next_tag() {
89        match tag.start_el() {
90            s if s.matches("Rule") /* Rules com.amazonaws.s3.synthetic#GetBucketLifecycleConfigurationOutput$Rules */ =>  {
91                let var_3 =
92                    Some(
93                        Result::<::std::vec::Vec::<crate::types::LifecycleRule>, ::aws_smithy_xml::decode::XmlDecodeError>::Ok({
94                            let mut list_4 = builder.rules.take().unwrap_or_default();
95                            list_4.push(
96                                crate::protocol_serde::shape_lifecycle_rule::de_lifecycle_rule(&mut tag)
97                                ?
98                            );
99                            list_4
100                        })
101                        ?
102                    )
103                ;
104                builder = builder.set_rules(var_3);
105            }
106            ,
107            _ => {}
108        }
109    }
110    Ok(builder)
111}