aws_sdk_s3/protocol_serde/
shape_put_bucket_notification_configuration.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_notification_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::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
9    crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
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_notification_configuration::PutBucketNotificationConfigurationError::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_notification_configuration::PutBucketNotificationConfigurationError::generic(generic))
18}
19
20#[allow(clippy::unnecessary_wraps)]
21pub fn de_put_bucket_notification_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::put_bucket_notification_configuration::PutBucketNotificationConfigurationOutput,
27    crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationError,
28> {
29    Ok({
30        #[allow(unused_mut)]
31        let mut output =
32            crate::operation::put_bucket_notification_configuration::builders::PutBucketNotificationConfigurationOutputBuilder::default();
33        output._set_extended_request_id(crate::s3_request_id::RequestIdExt::extended_request_id(_response_headers).map(str::to_string));
34        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
35        output.build()
36    })
37}
38
39pub fn ser_put_bucket_notification_configuration_headers(
40    input: &crate::operation::put_bucket_notification_configuration::PutBucketNotificationConfigurationInput,
41    mut builder: ::http::request::Builder,
42) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
43    if let ::std::option::Option::Some(inner_1) = &input.expected_bucket_owner {
44        let formatted_2 = inner_1.as_str();
45        let header_value = formatted_2;
46        let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
47            ::aws_smithy_types::error::operation::BuildError::invalid_field(
48                "expected_bucket_owner",
49                format!("`{}` cannot be used as a header value: {}", &header_value, err),
50            )
51        })?;
52        builder = builder.header("x-amz-expected-bucket-owner", header_value);
53    }
54    if let ::std::option::Option::Some(inner_3) = &input.skip_destination_validation {
55        let mut encoder = ::aws_smithy_types::primitive::Encoder::from(*inner_3);
56        let formatted_4 = encoder.encode();
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                "skip_destination_validation",
61                format!("`{}` cannot be used as a header value: {}", &header_value, err),
62            )
63        })?;
64        builder = builder.header("x-amz-skip-destination-validation", header_value);
65    }
66    Ok(builder)
67}