Server Test

Server Test

rev. 3c756f73b1f83a0eed4275d9d1e22df0b10b66fb

Files changed:

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_payload_blob_output.rs

@@ -0,1 +0,22 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_data_http_payload(
           4  +
    payload: ::std::option::Option<::aws_smithy_types::Blob>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:330 */
          12  +
                Vec::new(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:375 */
          19  +
        payload.into_inner(), /* HttpBoundProtocolPayloadGenerator.kt:343 */
          20  +
    )
          21  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          22  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_payload_structure.rs

@@ -0,1 +0,134 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_test_payload_structure_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::TestPayloadStructureInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::test_payload_structure_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          30  +
        if let Some(value) = {
          31  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
            if !bytes.is_empty() {
          33  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          34  +
                    &headers,
          35  +
                    Some("application/json"),
          36  +
                )?;
          37  +
            }
          38  +
            crate::protocol_serde::shape_test_payload_structure_input::de_payload_config_payload(
          39  +
                &bytes,
          40  +
            )?
          41  +
        } {
          42  +
            input = input.set_payload_config(Some(value))
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          45  +
        if let Some(value) =
          46  +
            crate::protocol_serde::shape_test_payload_structure_input::de_test_id_header(&headers)?
          47  +
        {
          48  +
            input = input.set_test_id(Some(value))
          49  +
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          51  +
        input.build()
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          53  +
    })
          54  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          55  +
}
          56  +
          57  +
/* RustType.kt:534 */
          58  +
#[allow(clippy::unnecessary_wraps)]
          59  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          60  +
pub fn ser_test_payload_structure_http_response(
          61  +
    #[allow(unused_variables)] output: crate::output::TestPayloadStructureOutput,
          62  +
) -> std::result::Result<
          63  +
    ::aws_smithy_legacy_http_server::response::Response,
          64  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          65  +
> {
          66  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          67  +
    Ok({
          68  +
        /* RustType.kt:534 */
          69  +
        #[allow(unused_mut)]
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          71  +
        let mut builder = ::http::Response::builder();
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          73  +
        builder = crate::protocol_serde::shape_test_payload_structure::ser_test_payload_structure_headers(&output, builder)?;
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          75  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          76  +
            builder,
          77  +
            ::http::header::CONTENT_TYPE,
          78  +
            "application/json",
          79  +
        );
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          81  +
        let http_status: u16 = 200;
          82  +
        builder = builder.status(http_status);
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          84  +
        let payload =
          85  +
            /* HttpBoundProtocolPayloadGenerator.kt:348 */crate::protocol_serde::shape_test_payload_structure_output::ser_payload_config_http_payload(& output.payload_config)?
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          88  +
        let content_length = payload.len();
          89  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          90  +
            builder,
          91  +
            ::http::header::CONTENT_LENGTH,
          92  +
            content_length,
          93  +
        );
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          95  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          97  +
        builder.body(body)?
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          99  +
    })
         100  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         101  +
}
         102  +
         103  +
/* HttpBindingGenerator.kt:565 */
         104  +
pub fn ser_test_payload_structure_headers(
         105  +
    input: &crate::output::TestPayloadStructureOutput,
         106  +
    mut builder: ::http::response::Builder,
         107  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         108  +
{
         109  +
    /* HttpBindingGenerator.kt:615 */
         110  +
    if let ::std::option::Option::Some(inner_1) = &input.test_id {
         111  +
        /* HttpBindingGenerator.kt:727 */
         112  +
        let formatted_2 = inner_1.as_str();
         113  +
        /* HttpBindingGenerator.kt:728 */
         114  +
        if !formatted_2.is_empty() {
         115  +
            /* HttpBindingGenerator.kt:729 */
         116  +
            let header_value = formatted_2;
         117  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         118  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         119  +
                    "test_id",
         120  +
                    format!(
         121  +
                        "`{}` cannot be used as a header value: {}",
         122  +
                        &header_value, err
         123  +
                    ),
         124  +
                )
         125  +
            })?;
         126  +
            builder = builder.header("x-amz-test-id", header_value);
         127  +
            /* HttpBindingGenerator.kt:728 */
         128  +
        }
         129  +
        /* HttpBindingGenerator.kt:615 */
         130  +
    }
         131  +
    /* HttpBindingGenerator.kt:578 */
         132  +
    Ok(builder)
         133  +
    /* HttpBindingGenerator.kt:565 */
         134  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_payload_structure_input.rs

@@ -0,1 +0,32 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_payload_config_payload(
           4  +
    body: &[u8],
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<crate::model::PayloadConfig>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
          10  +
    (!body.is_empty())
          11  +
        .then(|| {
          12  +
            /* ServerHttpBoundProtocolGenerator.kt:914 */
          13  +
            crate::protocol_serde::shape_payload_config::de_payload_config_payload(body)
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
          16  +
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
          18  +
}
          19  +
          20  +
/* HttpBindingGenerator.kt:159 */
          21  +
pub(crate) fn de_test_id_header(
          22  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          23  +
) -> ::std::result::Result<
          24  +
    ::std::option::Option<::std::string::String>,
          25  +
    ::aws_smithy_legacy_http::header::ParseError,
          26  +
> {
          27  +
    /* HttpBindingGenerator.kt:166 */
          28  +
    let headers = header_map.get_all("x-amz-test-id");
          29  +
    /* HttpBindingGenerator.kt:398 */
          30  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          31  +
    /* HttpBindingGenerator.kt:159 */
          32  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_payload_structure_output.rs

@@ -0,1 +0,44 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_payload_config_http_payload(
           4  +
    payload: &::std::option::Option<crate::model::PayloadConfig>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload.as_ref() {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:336 */
          12  +
                crate::protocol_serde::rest_json_unset_struct_payload(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:384 */
          19  +
        crate::protocol_serde::shape_test_payload_structure_output::ser_payload_config_payload(
          20  +
            payload,
          21  +
        )?, /* HttpBoundProtocolPayloadGenerator.kt:343 */
          22  +
    )
          23  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          24  +
}
          25  +
          26  +
/* JsonSerializerGenerator.kt:240 */
          27  +
pub fn ser_payload_config_payload(
          28  +
    input: &crate::model::PayloadConfig,
          29  +
) -> std::result::Result<
          30  +
    ::std::vec::Vec<u8>,
          31  +
    ::aws_smithy_types::error::operation::SerializationError,
          32  +
> {
          33  +
    /* JsonSerializerGenerator.kt:245 */
          34  +
    let mut out = String::new();
          35  +
    /* JsonSerializerGenerator.kt:246 */
          36  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          37  +
    /* JsonSerializerGenerator.kt:375 */
          38  +
    crate::protocol_serde::shape_payload_config::ser_payload_config(&mut object, input)?;
          39  +
    /* JsonSerializerGenerator.kt:252 */
          40  +
    object.finish();
          41  +
    /* JsonSerializerGenerator.kt:253 */
          42  +
    Ok(out.into_bytes())
          43  +
    /* JsonSerializerGenerator.kt:240 */
          44  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_post_no_input_no_payload.rs

@@ -0,1 +0,117 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_test_post_no_input_no_payload_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::TestPostNoInputNoPayloadInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::test_post_no_input_no_payload_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:873 */
          30  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          31  +
            &headers, None,
          32  +
        )?;
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          34  +
        input.build()
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          36  +
    })
          37  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          38  +
}
          39  +
          40  +
/* RustType.kt:534 */
          41  +
#[allow(clippy::unnecessary_wraps)]
          42  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          43  +
pub fn ser_test_post_no_input_no_payload_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::TestPostNoInputNoPayloadOutput,
          45  +
) -> std::result::Result<
          46  +
    ::aws_smithy_legacy_http_server::response::Response,
          47  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          48  +
> {
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          50  +
    Ok({
          51  +
        /* RustType.kt:534 */
          52  +
        #[allow(unused_mut)]
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          54  +
        let mut builder = ::http::Response::builder();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          56  +
        builder = crate::protocol_serde::shape_test_post_no_input_no_payload::ser_test_post_no_input_no_payload_headers(&output, builder)?;
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          58  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          59  +
            builder,
          60  +
            ::http::header::CONTENT_TYPE,
          61  +
            "application/json",
          62  +
        );
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          64  +
        let http_status: u16 = 200;
          65  +
        builder = builder.status(http_status);
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          67  +
        let payload =
          68  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_test_post_no_input_no_payload_output::ser_test_post_no_input_no_payload_output_output_output(&output)?
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          71  +
        let content_length = payload.len();
          72  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          73  +
            builder,
          74  +
            ::http::header::CONTENT_LENGTH,
          75  +
            content_length,
          76  +
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          78  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          80  +
        builder.body(body)?
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          82  +
    })
          83  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          84  +
}
          85  +
          86  +
/* HttpBindingGenerator.kt:565 */
          87  +
pub fn ser_test_post_no_input_no_payload_headers(
          88  +
    input: &crate::output::TestPostNoInputNoPayloadOutput,
          89  +
    mut builder: ::http::response::Builder,
          90  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          91  +
{
          92  +
    /* HttpBindingGenerator.kt:615 */
          93  +
    if let ::std::option::Option::Some(inner_1) = &input.test_id {
          94  +
        /* HttpBindingGenerator.kt:727 */
          95  +
        let formatted_2 = inner_1.as_str();
          96  +
        /* HttpBindingGenerator.kt:728 */
          97  +
        if !formatted_2.is_empty() {
          98  +
            /* HttpBindingGenerator.kt:729 */
          99  +
            let header_value = formatted_2;
         100  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         101  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         102  +
                    "test_id",
         103  +
                    format!(
         104  +
                        "`{}` cannot be used as a header value: {}",
         105  +
                        &header_value, err
         106  +
                    ),
         107  +
                )
         108  +
            })?;
         109  +
            builder = builder.header("X-Amz-Test-Id", header_value);
         110  +
            /* HttpBindingGenerator.kt:728 */
         111  +
        }
         112  +
        /* HttpBindingGenerator.kt:615 */
         113  +
    }
         114  +
    /* HttpBindingGenerator.kt:578 */
         115  +
    Ok(builder)
         116  +
    /* HttpBindingGenerator.kt:565 */
         117  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_post_no_input_no_payload_output.rs

@@ -0,1 +0,25 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_test_post_no_input_no_payload_output_output_output(
           4  +
    value: &crate::output::TestPostNoInputNoPayloadOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_test_post_no_input_no_payload_output::ser_test_post_no_input_no_payload_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_test_post_no_input_no_payload_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::TestPostNoInputNoPayloadOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
          23  +
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
          25  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_post_no_payload.rs

@@ -0,1 +0,122 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_test_post_no_payload_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::TestPostNoPayloadInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::test_post_no_payload_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          30  +
        if let Some(value) =
          31  +
            crate::protocol_serde::shape_test_post_no_payload_input::de_test_id_header(&headers)?
          32  +
        {
          33  +
            input = input.set_test_id(Some(value))
          34  +
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          36  +
        input.build()
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          38  +
    })
          39  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          40  +
}
          41  +
          42  +
/* RustType.kt:534 */
          43  +
#[allow(clippy::unnecessary_wraps)]
          44  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          45  +
pub fn ser_test_post_no_payload_http_response(
          46  +
    #[allow(unused_variables)] output: crate::output::TestPostNoPayloadOutput,
          47  +
) -> std::result::Result<
          48  +
    ::aws_smithy_legacy_http_server::response::Response,
          49  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          50  +
> {
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          52  +
    Ok({
          53  +
        /* RustType.kt:534 */
          54  +
        #[allow(unused_mut)]
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          56  +
        let mut builder = ::http::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          58  +
        builder =
          59  +
            crate::protocol_serde::shape_test_post_no_payload::ser_test_post_no_payload_headers(
          60  +
                &output, builder,
          61  +
            )?;
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          63  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          64  +
            builder,
          65  +
            ::http::header::CONTENT_TYPE,
          66  +
            "application/json",
          67  +
        );
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          69  +
        let http_status: u16 = 200;
          70  +
        builder = builder.status(http_status);
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          72  +
        let payload =
          73  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_test_post_no_payload_output::ser_test_post_no_payload_output_output_output(&output)?
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          76  +
        let content_length = payload.len();
          77  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          78  +
            builder,
          79  +
            ::http::header::CONTENT_LENGTH,
          80  +
            content_length,
          81  +
        );
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          83  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          85  +
        builder.body(body)?
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          87  +
    })
          88  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          89  +
}
          90  +
          91  +
/* HttpBindingGenerator.kt:565 */
          92  +
pub fn ser_test_post_no_payload_headers(
          93  +
    input: &crate::output::TestPostNoPayloadOutput,
          94  +
    mut builder: ::http::response::Builder,
          95  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          96  +
{
          97  +
    /* HttpBindingGenerator.kt:615 */
          98  +
    if let ::std::option::Option::Some(inner_1) = &input.test_id {
          99  +
        /* HttpBindingGenerator.kt:727 */
         100  +
        let formatted_2 = inner_1.as_str();
         101  +
        /* HttpBindingGenerator.kt:728 */
         102  +
        if !formatted_2.is_empty() {
         103  +
            /* HttpBindingGenerator.kt:729 */
         104  +
            let header_value = formatted_2;
         105  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         106  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         107  +
                    "test_id",
         108  +
                    format!(
         109  +
                        "`{}` cannot be used as a header value: {}",
         110  +
                        &header_value, err
         111  +
                    ),
         112  +
                )
         113  +
            })?;
         114  +
            builder = builder.header("X-Amz-Test-Id", header_value);
         115  +
            /* HttpBindingGenerator.kt:728 */
         116  +
        }
         117  +
        /* HttpBindingGenerator.kt:615 */
         118  +
    }
         119  +
    /* HttpBindingGenerator.kt:578 */
         120  +
    Ok(builder)
         121  +
    /* HttpBindingGenerator.kt:565 */
         122  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_post_no_payload_input.rs

@@ -0,1 +0,14 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_test_id_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<
           6  +
    ::std::option::Option<::std::string::String>,
           7  +
    ::aws_smithy_legacy_http::header::ParseError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
          10  +
    let headers = header_map.get_all("X-Amz-Test-Id");
          11  +
    /* HttpBindingGenerator.kt:398 */
          12  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:159 */
          14  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_post_no_payload_output.rs

@@ -0,1 +0,25 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_test_post_no_payload_output_output_output(
           4  +
    value: &crate::output::TestPostNoPayloadOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_test_post_no_payload_output::ser_test_post_no_payload_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_test_post_no_payload_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::TestPostNoPayloadOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
          23  +
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
          25  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_string_list.rs

@@ -0,1 +0,78 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_test_string_list<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::vec::Vec<::std::string::String>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
          23  +
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
          27  +
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
          29  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
          31  +
                        tokens.next().transpose().unwrap();
          32  +
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
          34  +
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
          36  +
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
          46  +
                        if let Some(value) = value {
          47  +
                            items.push(value);
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
          51  +
                            return Err(
          52  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                    "dense list cannot contain null values",
          54  +
                                ),
          55  +
                            );
          56  +
                        }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
          59  +
                }
          60  +
                /* JsonParserGenerator.kt:408 */
          61  +
            }
          62  +
            /* JsonParserGenerator.kt:446 */
          63  +
            Ok(Some(items))
          64  +
            /* JsonParserGenerator.kt:713 */
          65  +
        }
          66  +
        /* JsonParserGenerator.kt:722 */
          67  +
        _ => {
          68  +
            /* JsonParserGenerator.kt:723 */
          69  +
            Err(
          70  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          71  +
                    "expected start array or null",
          72  +
                ),
          73  +
            )
          74  +
            /* JsonParserGenerator.kt:722 */
          75  +
        } /* JsonParserGenerator.kt:712 */
          76  +
    }
          77  +
    /* JsonParserGenerator.kt:398 */
          78  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_test_string_map.rs

@@ -0,1 +0,87 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_test_string_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:474 */;
          45  +
                        /* JsonParserGenerator.kt:481 */
          46  +
                        match value {
          47  +
                            Some(value) => {
          48  +
                                map.insert(key, value);
          49  +
                            }
          50  +
                            None => {
          51  +
                                return Err(
          52  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                        "dense map cannot contain null values",
          54  +
                                    ),
          55  +
                                )
          56  +
                            }
          57  +
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
          59  +
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
          61  +
                    other => {
          62  +
                        return Err(
          63  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          64  +
                                format!("expected object key or end object, found: {other:?}"),
          65  +
                            ),
          66  +
                        )
          67  +
                    } /* JsonParserGenerator.kt:685 */
          68  +
                }
          69  +
                /* JsonParserGenerator.kt:684 */
          70  +
            }
          71  +
            /* JsonParserGenerator.kt:504 */
          72  +
            Ok(Some(map))
          73  +
            /* JsonParserGenerator.kt:713 */
          74  +
        }
          75  +
        /* JsonParserGenerator.kt:722 */
          76  +
        _ => {
          77  +
            /* JsonParserGenerator.kt:723 */
          78  +
            Err(
          79  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          80  +
                    "expected start object or null",
          81  +
                ),
          82  +
            )
          83  +
            /* JsonParserGenerator.kt:722 */
          84  +
        } /* JsonParserGenerator.kt:712 */
          85  +
    }
          86  +
    /* JsonParserGenerator.kt:460 */
          87  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_timestamp_format_headers.rs

@@ -0,1 +0,293 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_timestamp_format_headers_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::TimestampFormatHeadersInput,
           9  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
          22  +
        let mut input = crate::input::timestamp_format_headers_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          30  +
        if let Some(value) =
          31  +
            crate::protocol_serde::shape_timestamp_format_headers_input::de_default_format_header(
          32  +
                &headers,
          33  +
            )?
          34  +
        {
          35  +
            input = input.set_default_format(Some(value))
          36  +
        }
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          38  +
        if let Some(value) =
          39  +
            crate::protocol_serde::shape_timestamp_format_headers_input::de_member_date_time_header(
          40  +
                &headers,
          41  +
            )?
          42  +
        {
          43  +
            input = input.set_member_date_time(Some(value))
          44  +
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          46  +
        if let Some(value) = crate::protocol_serde::shape_timestamp_format_headers_input::de_member_epoch_seconds_header(&headers)? {
          47  +
                                input = input.set_member_epoch_seconds(Some(value))
          48  +
                            }
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          50  +
        if let Some(value) =
          51  +
            crate::protocol_serde::shape_timestamp_format_headers_input::de_member_http_date_header(
          52  +
                &headers,
          53  +
            )?
          54  +
        {
          55  +
            input = input.set_member_http_date(Some(value))
          56  +
        }
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          58  +
        if let Some(value) =
          59  +
            crate::protocol_serde::shape_timestamp_format_headers_input::de_target_date_time_header(
          60  +
                &headers,
          61  +
            )?
          62  +
        {
          63  +
            input = input.set_target_date_time(Some(value))
          64  +
        }
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          66  +
        if let Some(value) = crate::protocol_serde::shape_timestamp_format_headers_input::de_target_epoch_seconds_header(&headers)? {
          67  +
                                input = input.set_target_epoch_seconds(Some(value))
          68  +
                            }
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          70  +
        if let Some(value) =
          71  +
            crate::protocol_serde::shape_timestamp_format_headers_input::de_target_http_date_header(
          72  +
                &headers,
          73  +
            )?
          74  +
        {
          75  +
            input = input.set_target_http_date(Some(value))
          76  +
        }
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          78  +
        input.build()
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          80  +
    })
          81  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          82  +
}
          83  +
          84  +
/* RustType.kt:534 */
          85  +
#[allow(clippy::unnecessary_wraps)]
          86  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          87  +
pub fn ser_timestamp_format_headers_http_response(
          88  +
    #[allow(unused_variables)] output: crate::output::TimestampFormatHeadersOutput,
          89  +
) -> std::result::Result<
          90  +
    ::aws_smithy_legacy_http_server::response::Response,
          91  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          92  +
> {
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          94  +
    Ok({
          95  +
        /* RustType.kt:534 */
          96  +
        #[allow(unused_mut)]
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          98  +
        let mut builder = ::http::Response::builder();
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
         100  +
        builder = crate::protocol_serde::shape_timestamp_format_headers::ser_timestamp_format_headers_headers(&output, builder)?;
         101  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
         102  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         103  +
            builder,
         104  +
            ::http::header::CONTENT_TYPE,
         105  +
            "application/json",
         106  +
        );
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
         108  +
        let http_status: u16 = 200;
         109  +
        builder = builder.status(http_status);
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         111  +
        let payload =
         112  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_timestamp_format_headers_output::ser_timestamp_format_headers_output_output_output(&output)?
         113  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         115  +
        let content_length = payload.len();
         116  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         117  +
            builder,
         118  +
            ::http::header::CONTENT_LENGTH,
         119  +
            content_length,
         120  +
        );
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         122  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         124  +
        builder.body(body)?
         125  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         126  +
    })
         127  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         128  +
}
         129  +
         130  +
/* HttpBindingGenerator.kt:565 */
         131  +
pub fn ser_timestamp_format_headers_headers(
         132  +
    input: &crate::output::TimestampFormatHeadersOutput,
         133  +
    mut builder: ::http::response::Builder,
         134  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         135  +
{
         136  +
    /* HttpBindingGenerator.kt:615 */
         137  +
    if let ::std::option::Option::Some(inner_1) = &input.member_epoch_seconds {
         138  +
        /* HttpBindingGenerator.kt:727 */
         139  +
        let formatted_2 = inner_1.fmt(::aws_smithy_types::date_time::Format::EpochSeconds)?;
         140  +
        /* HttpBindingGenerator.kt:728 */
         141  +
        if !formatted_2.is_empty() {
         142  +
            /* HttpBindingGenerator.kt:729 */
         143  +
            let header_value = formatted_2;
         144  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         145  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         146  +
                    "member_epoch_seconds",
         147  +
                    format!(
         148  +
                        "`{}` cannot be used as a header value: {}",
         149  +
                        &header_value, err
         150  +
                    ),
         151  +
                )
         152  +
            })?;
         153  +
            builder = builder.header("X-memberEpochSeconds", header_value);
         154  +
            /* HttpBindingGenerator.kt:728 */
         155  +
        }
         156  +
        /* HttpBindingGenerator.kt:615 */
         157  +
    }
         158  +
    /* HttpBindingGenerator.kt:615 */
         159  +
    if let ::std::option::Option::Some(inner_3) = &input.member_http_date {
         160  +
        /* HttpBindingGenerator.kt:727 */
         161  +
        let formatted_4 = inner_3.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
         162  +
        /* HttpBindingGenerator.kt:728 */
         163  +
        if !formatted_4.is_empty() {
         164  +
            /* HttpBindingGenerator.kt:729 */
         165  +
            let header_value = formatted_4;
         166  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         167  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         168  +
                    "member_http_date",
         169  +
                    format!(
         170  +
                        "`{}` cannot be used as a header value: {}",
         171  +
                        &header_value, err
         172  +
                    ),
         173  +
                )
         174  +
            })?;
         175  +
            builder = builder.header("X-memberHttpDate", header_value);
         176  +
            /* HttpBindingGenerator.kt:728 */
         177  +
        }
         178  +
        /* HttpBindingGenerator.kt:615 */
         179  +
    }
         180  +
    /* HttpBindingGenerator.kt:615 */
         181  +
    if let ::std::option::Option::Some(inner_5) = &input.member_date_time {
         182  +
        /* HttpBindingGenerator.kt:727 */
         183  +
        let formatted_6 = inner_5.fmt(::aws_smithy_types::date_time::Format::DateTime)?;
         184  +
        /* HttpBindingGenerator.kt:728 */
         185  +
        if !formatted_6.is_empty() {
         186  +
            /* HttpBindingGenerator.kt:729 */
         187  +
            let header_value = formatted_6;
         188  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         189  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         190  +
                    "member_date_time",
         191  +
                    format!(
         192  +
                        "`{}` cannot be used as a header value: {}",
         193  +
                        &header_value, err
         194  +
                    ),
         195  +
                )
         196  +
            })?;
         197  +
            builder = builder.header("X-memberDateTime", header_value);
         198  +
            /* HttpBindingGenerator.kt:728 */
         199  +
        }
         200  +
        /* HttpBindingGenerator.kt:615 */
         201  +
    }
         202  +
    /* HttpBindingGenerator.kt:615 */
         203  +
    if let ::std::option::Option::Some(inner_7) = &input.default_format {
         204  +
        /* HttpBindingGenerator.kt:727 */
         205  +
        let formatted_8 = inner_7.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
         206  +
        /* HttpBindingGenerator.kt:728 */
         207  +
        if !formatted_8.is_empty() {
         208  +
            /* HttpBindingGenerator.kt:729 */
         209  +
            let header_value = formatted_8;
         210  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         211  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         212  +
                    "default_format",
         213  +
                    format!(
         214  +
                        "`{}` cannot be used as a header value: {}",
         215  +
                        &header_value, err
         216  +
                    ),
         217  +
                )
         218  +
            })?;
         219  +
            builder = builder.header("X-defaultFormat", header_value);
         220  +
            /* HttpBindingGenerator.kt:728 */
         221  +
        }
         222  +
        /* HttpBindingGenerator.kt:615 */
         223  +
    }
         224  +
    /* HttpBindingGenerator.kt:615 */
         225  +
    if let ::std::option::Option::Some(inner_9) = &input.target_epoch_seconds {
         226  +
        /* HttpBindingGenerator.kt:727 */
         227  +
        let formatted_10 = inner_9.fmt(::aws_smithy_types::date_time::Format::EpochSeconds)?;
         228  +
        /* HttpBindingGenerator.kt:728 */
         229  +
        if !formatted_10.is_empty() {
         230  +
            /* HttpBindingGenerator.kt:729 */
         231  +
            let header_value = formatted_10;
         232  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         233  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         234  +
                    "target_epoch_seconds",
         235  +
                    format!(
         236  +
                        "`{}` cannot be used as a header value: {}",
         237  +
                        &header_value, err
         238  +
                    ),
         239  +
                )
         240  +
            })?;
         241  +
            builder = builder.header("X-targetEpochSeconds", header_value);
         242  +
            /* HttpBindingGenerator.kt:728 */
         243  +
        }
         244  +
        /* HttpBindingGenerator.kt:615 */
         245  +
    }
         246  +
    /* HttpBindingGenerator.kt:615 */
         247  +
    if let ::std::option::Option::Some(inner_11) = &input.target_http_date {
         248  +
        /* HttpBindingGenerator.kt:727 */
         249  +
        let formatted_12 = inner_11.fmt(::aws_smithy_types::date_time::Format::HttpDate)?;
         250  +
        /* HttpBindingGenerator.kt:728 */
         251  +
        if !formatted_12.is_empty() {
         252  +
            /* HttpBindingGenerator.kt:729 */
         253  +
            let header_value = formatted_12;
         254  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         255  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         256  +
                    "target_http_date",
         257  +
                    format!(
         258  +
                        "`{}` cannot be used as a header value: {}",
         259  +
                        &header_value, err
         260  +
                    ),
         261  +
                )
         262  +
            })?;
         263  +
            builder = builder.header("X-targetHttpDate", header_value);
         264  +
            /* HttpBindingGenerator.kt:728 */
         265  +
        }
         266  +
        /* HttpBindingGenerator.kt:615 */
         267  +
    }
         268  +
    /* HttpBindingGenerator.kt:615 */
         269  +
    if let ::std::option::Option::Some(inner_13) = &input.target_date_time {
         270  +
        /* HttpBindingGenerator.kt:727 */
         271  +
        let formatted_14 = inner_13.fmt(::aws_smithy_types::date_time::Format::DateTime)?;
         272  +
        /* HttpBindingGenerator.kt:728 */
         273  +
        if !formatted_14.is_empty() {
         274  +
            /* HttpBindingGenerator.kt:729 */
         275  +
            let header_value = formatted_14;
         276  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         277  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         278  +
                    "target_date_time",
         279  +
                    format!(
         280  +
                        "`{}` cannot be used as a header value: {}",
         281  +
                        &header_value, err
         282  +
                    ),
         283  +
                )
         284  +
            })?;
         285  +
            builder = builder.header("X-targetDateTime", header_value);
         286  +
            /* HttpBindingGenerator.kt:728 */
         287  +
        }
         288  +
        /* HttpBindingGenerator.kt:615 */
         289  +
    }
         290  +
    /* HttpBindingGenerator.kt:578 */
         291  +
    Ok(builder)
         292  +
    /* HttpBindingGenerator.kt:565 */
         293  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_timestamp_format_headers_input.rs

@@ -0,1 +0,175 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_default_format_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<
           6  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
           7  +
    ::aws_smithy_legacy_http::header::ParseError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
          10  +
    let headers = header_map.get_all("X-defaultFormat");
          11  +
    /* HttpBindingGenerator.kt:417 */
          12  +
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::HttpDate)?
          13  +
    /* HttpBindingGenerator.kt:425 */;
          14  +
    /* HttpBindingGenerator.kt:491 */
          15  +
    if var_1.len() > 1 {
          16  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          17  +
            "expected one item but found {}",
          18  +
            var_1.len()
          19  +
        )))
          20  +
    } else {
          21  +
        let mut var_1 = var_1;
          22  +
        Ok(var_1.pop())
          23  +
    }
          24  +
    /* HttpBindingGenerator.kt:159 */
          25  +
}
          26  +
          27  +
/* HttpBindingGenerator.kt:159 */
          28  +
pub(crate) fn de_member_date_time_header(
          29  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          30  +
) -> ::std::result::Result<
          31  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
          32  +
    ::aws_smithy_legacy_http::header::ParseError,
          33  +
> {
          34  +
    /* HttpBindingGenerator.kt:166 */
          35  +
    let headers = header_map.get_all("X-memberDateTime");
          36  +
    /* HttpBindingGenerator.kt:417 */
          37  +
    let var_2: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::DateTime)?
          38  +
    /* HttpBindingGenerator.kt:425 */;
          39  +
    /* HttpBindingGenerator.kt:491 */
          40  +
    if var_2.len() > 1 {
          41  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          42  +
            "expected one item but found {}",
          43  +
            var_2.len()
          44  +
        )))
          45  +
    } else {
          46  +
        let mut var_2 = var_2;
          47  +
        Ok(var_2.pop())
          48  +
    }
          49  +
    /* HttpBindingGenerator.kt:159 */
          50  +
}
          51  +
          52  +
/* HttpBindingGenerator.kt:159 */
          53  +
pub(crate) fn de_member_epoch_seconds_header(
          54  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          55  +
) -> ::std::result::Result<
          56  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
          57  +
    ::aws_smithy_legacy_http::header::ParseError,
          58  +
> {
          59  +
    /* HttpBindingGenerator.kt:166 */
          60  +
    let headers = header_map.get_all("X-memberEpochSeconds");
          61  +
    /* HttpBindingGenerator.kt:417 */
          62  +
    let var_3: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::EpochSeconds)?
          63  +
    /* HttpBindingGenerator.kt:425 */;
          64  +
    /* HttpBindingGenerator.kt:491 */
          65  +
    if var_3.len() > 1 {
          66  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          67  +
            "expected one item but found {}",
          68  +
            var_3.len()
          69  +
        )))
          70  +
    } else {
          71  +
        let mut var_3 = var_3;
          72  +
        Ok(var_3.pop())
          73  +
    }
          74  +
    /* HttpBindingGenerator.kt:159 */
          75  +
}
          76  +
          77  +
/* HttpBindingGenerator.kt:159 */
          78  +
pub(crate) fn de_member_http_date_header(
          79  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          80  +
) -> ::std::result::Result<
          81  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
          82  +
    ::aws_smithy_legacy_http::header::ParseError,
          83  +
> {
          84  +
    /* HttpBindingGenerator.kt:166 */
          85  +
    let headers = header_map.get_all("X-memberHttpDate");
          86  +
    /* HttpBindingGenerator.kt:417 */
          87  +
    let var_4: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::HttpDate)?
          88  +
    /* HttpBindingGenerator.kt:425 */;
          89  +
    /* HttpBindingGenerator.kt:491 */
          90  +
    if var_4.len() > 1 {
          91  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          92  +
            "expected one item but found {}",
          93  +
            var_4.len()
          94  +
        )))
          95  +
    } else {
          96  +
        let mut var_4 = var_4;
          97  +
        Ok(var_4.pop())
          98  +
    }
          99  +
    /* HttpBindingGenerator.kt:159 */
         100  +
}
         101  +
         102  +
/* HttpBindingGenerator.kt:159 */
         103  +
pub(crate) fn de_target_date_time_header(
         104  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         105  +
) -> ::std::result::Result<
         106  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
         107  +
    ::aws_smithy_legacy_http::header::ParseError,
         108  +
> {
         109  +
    /* HttpBindingGenerator.kt:166 */
         110  +
    let headers = header_map.get_all("X-targetDateTime");
         111  +
    /* HttpBindingGenerator.kt:417 */
         112  +
    let var_5: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::DateTime)?
         113  +
    /* HttpBindingGenerator.kt:425 */;
         114  +
    /* HttpBindingGenerator.kt:491 */
         115  +
    if var_5.len() > 1 {
         116  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         117  +
            "expected one item but found {}",
         118  +
            var_5.len()
         119  +
        )))
         120  +
    } else {
         121  +
        let mut var_5 = var_5;
         122  +
        Ok(var_5.pop())
         123  +
    }
         124  +
    /* HttpBindingGenerator.kt:159 */
         125  +
}
         126  +
         127  +
/* HttpBindingGenerator.kt:159 */
         128  +
pub(crate) fn de_target_epoch_seconds_header(
         129  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         130  +
) -> ::std::result::Result<
         131  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
         132  +
    ::aws_smithy_legacy_http::header::ParseError,
         133  +
> {
         134  +
    /* HttpBindingGenerator.kt:166 */
         135  +
    let headers = header_map.get_all("X-targetEpochSeconds");
         136  +
    /* HttpBindingGenerator.kt:417 */
         137  +
    let var_6: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::EpochSeconds)?
         138  +
    /* HttpBindingGenerator.kt:425 */;
         139  +
    /* HttpBindingGenerator.kt:491 */
         140  +
    if var_6.len() > 1 {
         141  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         142  +
            "expected one item but found {}",
         143  +
            var_6.len()
         144  +
        )))
         145  +
    } else {
         146  +
        let mut var_6 = var_6;
         147  +
        Ok(var_6.pop())
         148  +
    }
         149  +
    /* HttpBindingGenerator.kt:159 */
         150  +
}
         151  +
         152  +
/* HttpBindingGenerator.kt:159 */
         153  +
pub(crate) fn de_target_http_date_header(
         154  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
         155  +
) -> ::std::result::Result<
         156  +
    ::std::option::Option<::aws_smithy_types::DateTime>,
         157  +
    ::aws_smithy_legacy_http::header::ParseError,
         158  +
> {
         159  +
    /* HttpBindingGenerator.kt:166 */
         160  +
    let headers = header_map.get_all("X-targetHttpDate");
         161  +
    /* HttpBindingGenerator.kt:417 */
         162  +
    let var_7: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_legacy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::HttpDate)?
         163  +
    /* HttpBindingGenerator.kt:425 */;
         164  +
    /* HttpBindingGenerator.kt:491 */
         165  +
    if var_7.len() > 1 {
         166  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
         167  +
            "expected one item but found {}",
         168  +
            var_7.len()
         169  +
        )))
         170  +
    } else {
         171  +
        let mut var_7 = var_7;
         172  +
        Ok(var_7.pop())
         173  +
    }
         174  +
    /* HttpBindingGenerator.kt:159 */
         175  +
}