aws_sdk_s3/protocol_serde/
shape_put_bucket_request_payment.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_put_bucket_request_payment_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::put_bucket_request_payment::PutBucketRequestPaymentOutput,
9    crate::operation::put_bucket_request_payment::PutBucketRequestPaymentError,
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::put_bucket_request_payment::PutBucketRequestPaymentError::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::put_bucket_request_payment::PutBucketRequestPaymentError::generic(
18        generic,
19    ))
20}
21
22#[allow(clippy::unnecessary_wraps)]
23pub fn de_put_bucket_request_payment_http_response(
24    _response_status: u16,
25    _response_headers: &::aws_smithy_runtime_api::http::Headers,
26    _response_body: &[u8],
27) -> std::result::Result<
28    crate::operation::put_bucket_request_payment::PutBucketRequestPaymentOutput,
29    crate::operation::put_bucket_request_payment::PutBucketRequestPaymentError,
30> {
31    Ok({
32        #[allow(unused_mut)]
33        let mut output = crate::operation::put_bucket_request_payment::builders::PutBucketRequestPaymentOutputBuilder::default();
34        output._set_extended_request_id(crate::s3_request_id::RequestIdExt::extended_request_id(_response_headers).map(str::to_string));
35        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
36        output.build()
37    })
38}
39
40pub fn ser_put_bucket_request_payment_headers(
41    input: &crate::operation::put_bucket_request_payment::PutBucketRequestPaymentInput,
42    mut builder: ::http::request::Builder,
43) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
44    if let ::std::option::Option::Some(inner_1) = &input.content_md5 {
45        let formatted_2 = inner_1.as_str();
46        let header_value = formatted_2;
47        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
48            ::aws_smithy_types::error::operation::BuildError::invalid_field(
49                "content_md5",
50                format!("`{}` cannot be used as a header value: {}", &header_value, err),
51            )
52        })?;
53        builder = builder.header("Content-MD5", header_value);
54    }
55    if let ::std::option::Option::Some(inner_3) = &input.checksum_algorithm {
56        let formatted_4 = inner_3.as_str();
57        let header_value = formatted_4;
58        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
59            ::aws_smithy_types::error::operation::BuildError::invalid_field(
60                "checksum_algorithm",
61                format!("`{}` cannot be used as a header value: {}", &header_value, err),
62            )
63        })?;
64        builder = builder.header("x-amz-sdk-checksum-algorithm", header_value);
65    }
66    if let ::std::option::Option::Some(inner_5) = &input.expected_bucket_owner {
67        let formatted_6 = inner_5.as_str();
68        let header_value = formatted_6;
69        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
70            ::aws_smithy_types::error::operation::BuildError::invalid_field(
71                "expected_bucket_owner",
72                format!("`{}` cannot be used as a header value: {}", &header_value, err),
73            )
74        })?;
75        builder = builder.header("x-amz-expected-bucket-owner", header_value);
76    }
77    Ok(builder)
78}