Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,91 @@
           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_http_payload_with_union_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPayloadWithUnionInput,
           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::http_payload_with_union_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_http_payload_with_union_input::de_nested_payload(&bytes)?
          39  +
        } {
          40  +
            input = input.set_nested(Some(value))
          41  +
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          43  +
        input.build()
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          45  +
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          47  +
}
          48  +
          49  +
/* RustType.kt:534 */
          50  +
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          52  +
pub fn ser_http_payload_with_union_http_response(
          53  +
    #[allow(unused_variables)] output: crate::output::HttpPayloadWithUnionOutput,
          54  +
) -> std::result::Result<
          55  +
    ::aws_smithy_legacy_http_server::response::Response,
          56  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          57  +
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          59  +
    Ok({
          60  +
        /* RustType.kt:534 */
          61  +
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          63  +
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          65  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          66  +
            builder,
          67  +
            ::http::header::CONTENT_TYPE,
          68  +
            "application/json",
          69  +
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          71  +
        let http_status: u16 = 200;
          72  +
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          74  +
        let payload =
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:348 */crate::protocol_serde::shape_http_payload_with_union_output::ser_nested_http_payload(& output.nested)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          78  +
        let content_length = payload.len();
          79  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
            builder,
          81  +
            ::http::header::CONTENT_LENGTH,
          82  +
            content_length,
          83  +
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          85  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          87  +
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          89  +
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          91  +
}

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

@@ -0,1 +0,18 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_nested_payload(
           4  +
    body: &[u8],
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<crate::model::UnionPayload>,
           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_union_payload::de_union_payload_payload(body)
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
          16  +
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
          18  +
}

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

@@ -0,1 +0,42 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_nested_http_payload(
           4  +
    payload: &::std::option::Option<crate::model::UnionPayload>,
           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:337 */
          12  +
                crate::protocol_serde::rest_json_unset_union_payload(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:384 */
          19  +
        crate::protocol_serde::shape_http_payload_with_union_output::ser_nested_payload(payload)?, /* HttpBoundProtocolPayloadGenerator.kt:343 */
          20  +
    )
          21  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          22  +
}
          23  +
          24  +
/* JsonSerializerGenerator.kt:240 */
          25  +
pub fn ser_nested_payload(
          26  +
    input: &crate::model::UnionPayload,
          27  +
) -> std::result::Result<
          28  +
    ::std::vec::Vec<u8>,
          29  +
    ::aws_smithy_types::error::operation::SerializationError,
          30  +
> {
          31  +
    /* JsonSerializerGenerator.kt:245 */
          32  +
    let mut out = String::new();
          33  +
    /* JsonSerializerGenerator.kt:246 */
          34  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          35  +
    /* JsonSerializerGenerator.kt:579 */
          36  +
    crate::protocol_serde::shape_union_payload::ser_union_payload(&mut object, input)?;
          37  +
    /* JsonSerializerGenerator.kt:252 */
          38  +
    object.finish();
          39  +
    /* JsonSerializerGenerator.kt:253 */
          40  +
    Ok(out.into_bytes())
          41  +
    /* JsonSerializerGenerator.kt:240 */
          42  +
}

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

@@ -0,1 +0,157 @@
           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_http_prefix_headers_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPrefixHeadersInput,
           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::http_prefix_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_http_prefix_headers_input::de_foo_header(&headers)?
          32  +
        {
          33  +
            input = input.set_foo(Some(value))
          34  +
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          36  +
        if let Some(value) =
          37  +
            crate::protocol_serde::shape_http_prefix_headers_input::de_foo_map_prefix_header(
          38  +
                &headers,
          39  +
            )?
          40  +
        {
          41  +
            input = input.set_foo_map(Some(value))
          42  +
        }
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          44  +
        input.build()
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          46  +
    })
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          48  +
}
          49  +
          50  +
/* RustType.kt:534 */
          51  +
#[allow(clippy::unnecessary_wraps)]
          52  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          53  +
pub fn ser_http_prefix_headers_http_response(
          54  +
    #[allow(unused_variables)] output: crate::output::HttpPrefixHeadersOutput,
          55  +
) -> std::result::Result<
          56  +
    ::aws_smithy_legacy_http_server::response::Response,
          57  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          58  +
> {
          59  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          60  +
    Ok({
          61  +
        /* RustType.kt:534 */
          62  +
        #[allow(unused_mut)]
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          64  +
        let mut builder = ::http::Response::builder();
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          66  +
        builder =
          67  +
            crate::protocol_serde::shape_http_prefix_headers::ser_http_prefix_headers_headers(
          68  +
                &output, builder,
          69  +
            )?;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          71  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          72  +
            builder,
          73  +
            ::http::header::CONTENT_TYPE,
          74  +
            "application/json",
          75  +
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          77  +
        let http_status: u16 = 200;
          78  +
        builder = builder.status(http_status);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          80  +
        let payload =
          81  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_http_prefix_headers_output::ser_http_prefix_headers_output_output_output(&output)?
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          84  +
        let content_length = payload.len();
          85  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          86  +
            builder,
          87  +
            ::http::header::CONTENT_LENGTH,
          88  +
            content_length,
          89  +
        );
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          91  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          93  +
        builder.body(body)?
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          95  +
    })
          96  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          97  +
}
          98  +
          99  +
/* HttpBindingGenerator.kt:565 */
         100  +
pub fn ser_http_prefix_headers_headers(
         101  +
    input: &crate::output::HttpPrefixHeadersOutput,
         102  +
    mut builder: ::http::response::Builder,
         103  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         104  +
{
         105  +
    /* HttpBindingGenerator.kt:615 */
         106  +
    if let ::std::option::Option::Some(inner_1) = &input.foo {
         107  +
        /* HttpBindingGenerator.kt:727 */
         108  +
        let formatted_2 = inner_1.as_str();
         109  +
        /* HttpBindingGenerator.kt:728 */
         110  +
        if !formatted_2.is_empty() {
         111  +
            /* HttpBindingGenerator.kt:729 */
         112  +
            let header_value = formatted_2;
         113  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         114  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         115  +
                    "foo",
         116  +
                    format!(
         117  +
                        "`{}` cannot be used as a header value: {}",
         118  +
                        &header_value, err
         119  +
                    ),
         120  +
                )
         121  +
            })?;
         122  +
            builder = builder.header("x-foo", header_value);
         123  +
            /* HttpBindingGenerator.kt:728 */
         124  +
        }
         125  +
        /* HttpBindingGenerator.kt:615 */
         126  +
    }
         127  +
    /* HttpBindingGenerator.kt:764 */
         128  +
    if let ::std::option::Option::Some(inner_3) = &input.foo_map {
         129  +
        /* HttpBindingGenerator.kt:764 */
         130  +
        {
         131  +
            /* HttpBindingGenerator.kt:770 */
         132  +
            for (k, v) in inner_3 {
         133  +
                use std::str::FromStr;
         134  +
                let header_name = ::http::HeaderName::from_str(&format!("{}{}", "x-foo-", &k))
         135  +
                    .map_err(|err| {
         136  +
                        ::aws_smithy_types::error::operation::BuildError::invalid_field(
         137  +
                            "foo_map",
         138  +
                            format!("`{k}` cannot be used as a header name: {err}"),
         139  +
                        )
         140  +
                    })?;
         141  +
                let header_value = v.as_str();
         142  +
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         143  +
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
         144  +
                        "foo_map",
         145  +
                        format!("`{v}` cannot be used as a header value: {err}"),
         146  +
                    )
         147  +
                })?;
         148  +
                builder = builder.header(header_name, header_value);
         149  +
            }
         150  +
            /* HttpBindingGenerator.kt:764 */
         151  +
        }
         152  +
        /* HttpBindingGenerator.kt:764 */
         153  +
    }
         154  +
    /* HttpBindingGenerator.kt:578 */
         155  +
    Ok(builder)
         156  +
    /* HttpBindingGenerator.kt:565 */
         157  +
}

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

@@ -0,1 +0,118 @@
           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_http_prefix_headers_in_response_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPrefixHeadersInResponseInput,
           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::http_prefix_headers_in_response_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:896 */
          30  +
        input.build()
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          32  +
    })
          33  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          34  +
}
          35  +
          36  +
/* RustType.kt:534 */
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          39  +
pub fn ser_http_prefix_headers_in_response_http_response(
          40  +
    #[allow(unused_variables)] output: crate::output::HttpPrefixHeadersInResponseOutput,
          41  +
) -> std::result::Result<
          42  +
    ::aws_smithy_legacy_http_server::response::Response,
          43  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          44  +
> {
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          46  +
    Ok({
          47  +
        /* RustType.kt:534 */
          48  +
        #[allow(unused_mut)]
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          50  +
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          52  +
        builder = crate::protocol_serde::shape_http_prefix_headers_in_response::ser_http_prefix_headers_in_response_headers(&output, builder)?;
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          54  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          55  +
            builder,
          56  +
            ::http::header::CONTENT_TYPE,
          57  +
            "application/json",
          58  +
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          60  +
        let http_status: u16 = 200;
          61  +
        builder = builder.status(http_status);
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          63  +
        let payload =
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_http_prefix_headers_in_response_output::ser_http_prefix_headers_in_response_output_output_output(&output)?
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          67  +
        let content_length = payload.len();
          68  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          69  +
            builder,
          70  +
            ::http::header::CONTENT_LENGTH,
          71  +
            content_length,
          72  +
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          74  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          76  +
        builder.body(body)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          78  +
    })
          79  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          80  +
}
          81  +
          82  +
/* HttpBindingGenerator.kt:565 */
          83  +
pub fn ser_http_prefix_headers_in_response_headers(
          84  +
    input: &crate::output::HttpPrefixHeadersInResponseOutput,
          85  +
    mut builder: ::http::response::Builder,
          86  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          87  +
{
          88  +
    /* HttpBindingGenerator.kt:764 */
          89  +
    if let ::std::option::Option::Some(inner_1) = &input.prefix_headers {
          90  +
        /* HttpBindingGenerator.kt:764 */
          91  +
        {
          92  +
            /* HttpBindingGenerator.kt:770 */
          93  +
            for (k, v) in inner_1 {
          94  +
                use std::str::FromStr;
          95  +
                let header_name =
          96  +
                    ::http::HeaderName::from_str(&format!("{}{}", "", &k)).map_err(|err| {
          97  +
                        ::aws_smithy_types::error::operation::BuildError::invalid_field(
          98  +
                            "prefix_headers",
          99  +
                            format!("`{k}` cannot be used as a header name: {err}"),
         100  +
                        )
         101  +
                    })?;
         102  +
                let header_value = v.as_str();
         103  +
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         104  +
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
         105  +
                        "prefix_headers",
         106  +
                        format!("`{v}` cannot be used as a header value: {err}"),
         107  +
                    )
         108  +
                })?;
         109  +
                builder = builder.header(header_name, header_value);
         110  +
            }
         111  +
            /* HttpBindingGenerator.kt:764 */
         112  +
        }
         113  +
        /* HttpBindingGenerator.kt:764 */
         114  +
    }
         115  +
    /* HttpBindingGenerator.kt:578 */
         116  +
    Ok(builder)
         117  +
    /* HttpBindingGenerator.kt:565 */
         118  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_http_prefix_headers_in_response_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_http_prefix_headers_in_response_output_output_output(
           4  +
    value: &crate::output::HttpPrefixHeadersInResponseOutput,
           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_http_prefix_headers_in_response_output::ser_http_prefix_headers_in_response_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_http_prefix_headers_in_response_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::HttpPrefixHeadersInResponseOutput,
          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_http_prefix_headers_input.rs

@@ -0,1 +0,49 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_foo_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-foo");
          11  +
    /* HttpBindingGenerator.kt:398 */
          12  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:159 */
          14  +
}
          15  +
          16  +
/* HttpBindingGenerator.kt:190 */
          17  +
pub(crate) fn de_foo_map_prefix_header(
          18  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          19  +
) -> std::result::Result<
          20  +
    ::std::option::Option<
          21  +
        ::std::collections::HashMap<::std::string::String, ::std::string::String>,
          22  +
    >,
          23  +
    ::aws_smithy_legacy_http::header::ParseError,
          24  +
> {
          25  +
    /* HttpBindingGenerator.kt:196 */
          26  +
    let headers = ::aws_smithy_legacy_http::header::headers_for_prefix(
          27  +
        header_map.iter().map(|(k, _)| k),
          28  +
        "x-foo-",
          29  +
    );
          30  +
    let out: std::result::Result<_, _> = headers.map(|(key, header_name)| {
          31  +
                            let values = header_map.get_all(header_name);
          32  +
                            crate::protocol_serde::shape_http_prefix_headers_input::de_foo_map_inner(values).map(|v| (key.to_string(), v.expect(
          33  +
                                "we have checked there is at least one value for this header name; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues"
          34  +
                            )))
          35  +
                        }).collect();
          36  +
    /* HttpBindingGenerator.kt:217 */
          37  +
    out.map(Some)
          38  +
    /* HttpBindingGenerator.kt:190 */
          39  +
}
          40  +
          41  +
/* HttpBindingGenerator.kt:179 */
          42  +
pub fn de_foo_map_inner<'a>(
          43  +
    headers: impl ::std::iter::Iterator<Item = &'a str>,
          44  +
) -> std::result::Result<Option<::std::string::String>, ::aws_smithy_legacy_http::header::ParseError>
          45  +
{
          46  +
    /* HttpBindingGenerator.kt:398 */
          47  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          48  +
    /* HttpBindingGenerator.kt:179 */
          49  +
}

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

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_http_prefix_headers_output_output_output(
           4  +
    value: &crate::output::HttpPrefixHeadersOutput,
           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_http_prefix_headers_output::ser_http_prefix_headers_output_output(
          11  +
        &mut object,
          12  +
        value,
          13  +
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
          15  +
    object.finish();
          16  +
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
          18  +
}
          19  +
          20  +
/* JsonSerializerGenerator.kt:358 */
          21  +
pub fn ser_http_prefix_headers_output_output(
          22  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    #[allow(unused_variables)] input: &crate::output::HttpPrefixHeadersOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:372 */
          26  +
    Ok(())
          27  +
    /* JsonSerializerGenerator.kt:358 */
          28  +
}

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

@@ -0,1 +0,165 @@
           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_http_request_with_float_labels_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpRequestWithFloatLabelsInput,
           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::http_request_with_float_labels_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:1134 */
          30  +
        let input_string = uri.path();
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
          32  +
        let (input_string, (_, m1, m2)) =
          33  +
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
          34  +
                ::nom::sequence::preceded(
          35  +
                    ::nom::bytes::complete::tag("/"),
          36  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
          37  +
                        "FloatHttpLabels",
          38  +
                    ),
          39  +
                ),
          40  +
                ::nom::sequence::preceded(
          41  +
                    ::nom::bytes::complete::tag("/"),
          42  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          43  +
                        ::nom::bytes::complete::take_until("/"),
          44  +
                        ::nom::combinator::rest,
          45  +
                    )),
          46  +
                ),
          47  +
                ::nom::sequence::preceded(
          48  +
                    ::nom::bytes::complete::tag("/"),
          49  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          50  +
                        ::nom::bytes::complete::take_until("/"),
          51  +
                        ::nom::combinator::rest,
          52  +
                    )),
          53  +
                ),
          54  +
            ))(input_string)?;
          55  +
        debug_assert_eq!("", input_string);
          56  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          57  +
        input = input.set_float(
          58  +
            crate::protocol_serde::shape_http_request_with_float_labels_input::de_float(m1)?,
          59  +
        );
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          61  +
        input = input.set_double(
          62  +
            crate::protocol_serde::shape_http_request_with_float_labels_input::de_double(m2)?,
          63  +
        );
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          65  +
        input.build()?
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          67  +
    })
          68  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          69  +
}
          70  +
          71  +
/* RustType.kt:534 */
          72  +
#[allow(clippy::unnecessary_wraps)]
          73  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          74  +
pub fn ser_http_request_with_float_labels_http_response(
          75  +
    #[allow(unused_variables)] output: crate::output::HttpRequestWithFloatLabelsOutput,
          76  +
) -> std::result::Result<
          77  +
    ::aws_smithy_legacy_http_server::response::Response,
          78  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          79  +
> {
          80  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          81  +
    Ok({
          82  +
        /* RustType.kt:534 */
          83  +
        #[allow(unused_mut)]
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          85  +
        let mut builder = ::http::Response::builder();
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          87  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          88  +
            builder,
          89  +
            ::http::header::CONTENT_TYPE,
          90  +
            "application/json",
          91  +
        );
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          93  +
        let http_status: u16 = 200;
          94  +
        builder = builder.status(http_status);
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          96  +
        let payload =
          97  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         100  +
        let content_length = payload.len();
         101  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         102  +
            builder,
         103  +
            ::http::header::CONTENT_LENGTH,
         104  +
            content_length,
         105  +
        );
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         107  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         108  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         109  +
        builder.body(body)?
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         111  +
    })
         112  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         113  +
}
         114  +
         115  +
/* RustType.kt:534 */
         116  +
#[allow(clippy::unnecessary_wraps)]
         117  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
         118  +
pub fn ser_http_request_with_float_labels_http_error(
         119  +
    error: &crate::error::HttpRequestWithFloatLabelsError,
         120  +
) -> std::result::Result<
         121  +
    ::aws_smithy_legacy_http_server::response::Response,
         122  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         123  +
> {
         124  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         125  +
    Ok({
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         127  +
        match error {
         128  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         129  +
            crate::error::HttpRequestWithFloatLabelsError::ValidationException(output) => {
         130  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         131  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         132  +
                /* RustType.kt:534 */
         133  +
                #[allow(unused_mut)]
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         135  +
                let mut builder = ::http::Response::builder();
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         137  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         138  +
                    builder,
         139  +
                    ::http::header::CONTENT_TYPE,
         140  +
                    "application/json",
         141  +
                );
         142  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         143  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         144  +
                    builder,
         145  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         146  +
                    "ValidationException",
         147  +
                );
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         149  +
                let content_length = payload.len();
         150  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         151  +
                    builder,
         152  +
                    ::http::header::CONTENT_LENGTH,
         153  +
                    content_length,
         154  +
                );
         155  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         156  +
                builder
         157  +
                    .status(400)
         158  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         160  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         161  +
        }
         162  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         163  +
    })
         164  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         165  +
}

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

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
           3  +
pub fn de_float(
           4  +
    value: &str,
           5  +
) -> std::result::Result<
           6  +
    f32,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
          10  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          11  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          12  +
    Ok(value)
          13  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          14  +
}
          15  +
          16  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
          17  +
pub fn de_double(
          18  +
    value: &str,
          19  +
) -> std::result::Result<
          20  +
    f64,
          21  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          22  +
> {
          23  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
          24  +
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          25  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          26  +
    Ok(value)
          27  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          28  +
}

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

@@ -0,1 +0,171 @@
           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_http_request_with_greedy_label_in_path_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpRequestWithGreedyLabelInPathInput,
           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 =
          23  +
            crate::input::http_request_with_greedy_label_in_path_input::Builder::default();
          24  +
        /* RustType.kt:534 */
          25  +
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          27  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          28  +
            uri, headers, body, ..
          29  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
          31  +
        let input_string = uri.path();
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
          33  +
        let (input_string, (_, _, m2, _, m4)) =
          34  +
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
          35  +
                ::nom::sequence::preceded(
          36  +
                    ::nom::bytes::complete::tag("/"),
          37  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
          38  +
                        "HttpRequestWithGreedyLabelInPath",
          39  +
                    ),
          40  +
                ),
          41  +
                ::nom::sequence::preceded(
          42  +
                    ::nom::bytes::complete::tag("/"),
          43  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("foo"),
          44  +
                ),
          45  +
                ::nom::sequence::preceded(
          46  +
                    ::nom::bytes::complete::tag("/"),
          47  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          48  +
                        ::nom::bytes::complete::take_until("/"),
          49  +
                        ::nom::combinator::rest,
          50  +
                    )),
          51  +
                ),
          52  +
                ::nom::sequence::preceded(
          53  +
                    ::nom::bytes::complete::tag("/"),
          54  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("baz"),
          55  +
                ),
          56  +
                ::nom::sequence::preceded(
          57  +
                    ::nom::bytes::complete::tag("/"),
          58  +
                    ::nom::combinator::rest::<_, ::nom::error::Error<&str>>,
          59  +
                ),
          60  +
            ))(input_string)?;
          61  +
        debug_assert_eq!("", input_string);
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          63  +
        input = input.set_foo(
          64  +
            crate::protocol_serde::shape_http_request_with_greedy_label_in_path_input::de_foo(m2)?,
          65  +
        );
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          67  +
        input = input.set_baz(
          68  +
            crate::protocol_serde::shape_http_request_with_greedy_label_in_path_input::de_baz(m4)?,
          69  +
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          71  +
        input.build()?
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          73  +
    })
          74  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          75  +
}
          76  +
          77  +
/* RustType.kt:534 */
          78  +
#[allow(clippy::unnecessary_wraps)]
          79  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          80  +
pub fn ser_http_request_with_greedy_label_in_path_http_response(
          81  +
    #[allow(unused_variables)] output: crate::output::HttpRequestWithGreedyLabelInPathOutput,
          82  +
) -> std::result::Result<
          83  +
    ::aws_smithy_legacy_http_server::response::Response,
          84  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          85  +
> {
          86  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          87  +
    Ok({
          88  +
        /* RustType.kt:534 */
          89  +
        #[allow(unused_mut)]
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          91  +
        let mut builder = ::http::Response::builder();
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          93  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          94  +
            builder,
          95  +
            ::http::header::CONTENT_TYPE,
          96  +
            "application/json",
          97  +
        );
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          99  +
        let http_status: u16 = 200;
         100  +
        builder = builder.status(http_status);
         101  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         102  +
        let payload =
         103  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         105  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         106  +
        let content_length = payload.len();
         107  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         108  +
            builder,
         109  +
            ::http::header::CONTENT_LENGTH,
         110  +
            content_length,
         111  +
        );
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         113  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         115  +
        builder.body(body)?
         116  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         117  +
    })
         118  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         119  +
}
         120  +
         121  +
/* RustType.kt:534 */
         122  +
#[allow(clippy::unnecessary_wraps)]
         123  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
         124  +
pub fn ser_http_request_with_greedy_label_in_path_http_error(
         125  +
    error: &crate::error::HttpRequestWithGreedyLabelInPathError,
         126  +
) -> std::result::Result<
         127  +
    ::aws_smithy_legacy_http_server::response::Response,
         128  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         129  +
> {
         130  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         131  +
    Ok({
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         133  +
        match error {
         134  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         135  +
            crate::error::HttpRequestWithGreedyLabelInPathError::ValidationException(output) => {
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         137  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         138  +
                /* RustType.kt:534 */
         139  +
                #[allow(unused_mut)]
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         141  +
                let mut builder = ::http::Response::builder();
         142  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         143  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         144  +
                    builder,
         145  +
                    ::http::header::CONTENT_TYPE,
         146  +
                    "application/json",
         147  +
                );
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         149  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         150  +
                    builder,
         151  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         152  +
                    "ValidationException",
         153  +
                );
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         155  +
                let content_length = payload.len();
         156  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         157  +
                    builder,
         158  +
                    ::http::header::CONTENT_LENGTH,
         159  +
                    content_length,
         160  +
                );
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         162  +
                builder
         163  +
                    .status(400)
         164  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         165  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         166  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         167  +
        }
         168  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         169  +
    })
         170  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         171  +
}

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

@@ -0,1 +0,32 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
           3  +
pub fn de_foo(
           4  +
    value: &str,
           5  +
) -> std::result::Result<
           6  +
    ::std::string::String,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1463 */
          10  +
    let value = ::percent_encoding::percent_decode_str(value)
          11  +
        .decode_utf8()?
          12  +
        .into_owned();
          13  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          14  +
    Ok(value)
          15  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          16  +
}
          17  +
          18  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
          19  +
pub fn de_baz(
          20  +
    value: &str,
          21  +
) -> std::result::Result<
          22  +
    ::std::string::String,
          23  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          24  +
> {
          25  +
    /* ServerHttpBoundProtocolGenerator.kt:1463 */
          26  +
    let value = ::percent_encoding::percent_decode_str(value)
          27  +
        .decode_utf8()?
          28  +
        .into_owned();
          29  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          30  +
    Ok(value)
          31  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          32  +
}

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

@@ -0,1 +0,228 @@
           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_http_request_with_labels_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpRequestWithLabelsInput,
           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::http_request_with_labels_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:1134 */
          30  +
        let input_string = uri.path();
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
          32  +
        let (input_string, (_, m1, m2, m3, m4, m5, m6, m7, m8)) =
          33  +
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
          34  +
                ::nom::sequence::preceded(
          35  +
                    ::nom::bytes::complete::tag("/"),
          36  +
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
          37  +
                        "HttpRequestWithLabels",
          38  +
                    ),
          39  +
                ),
          40  +
                ::nom::sequence::preceded(
          41  +
                    ::nom::bytes::complete::tag("/"),
          42  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          43  +
                        ::nom::bytes::complete::take_until("/"),
          44  +
                        ::nom::combinator::rest,
          45  +
                    )),
          46  +
                ),
          47  +
                ::nom::sequence::preceded(
          48  +
                    ::nom::bytes::complete::tag("/"),
          49  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          50  +
                        ::nom::bytes::complete::take_until("/"),
          51  +
                        ::nom::combinator::rest,
          52  +
                    )),
          53  +
                ),
          54  +
                ::nom::sequence::preceded(
          55  +
                    ::nom::bytes::complete::tag("/"),
          56  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          57  +
                        ::nom::bytes::complete::take_until("/"),
          58  +
                        ::nom::combinator::rest,
          59  +
                    )),
          60  +
                ),
          61  +
                ::nom::sequence::preceded(
          62  +
                    ::nom::bytes::complete::tag("/"),
          63  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          64  +
                        ::nom::bytes::complete::take_until("/"),
          65  +
                        ::nom::combinator::rest,
          66  +
                    )),
          67  +
                ),
          68  +
                ::nom::sequence::preceded(
          69  +
                    ::nom::bytes::complete::tag("/"),
          70  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          71  +
                        ::nom::bytes::complete::take_until("/"),
          72  +
                        ::nom::combinator::rest,
          73  +
                    )),
          74  +
                ),
          75  +
                ::nom::sequence::preceded(
          76  +
                    ::nom::bytes::complete::tag("/"),
          77  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          78  +
                        ::nom::bytes::complete::take_until("/"),
          79  +
                        ::nom::combinator::rest,
          80  +
                    )),
          81  +
                ),
          82  +
                ::nom::sequence::preceded(
          83  +
                    ::nom::bytes::complete::tag("/"),
          84  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          85  +
                        ::nom::bytes::complete::take_until("/"),
          86  +
                        ::nom::combinator::rest,
          87  +
                    )),
          88  +
                ),
          89  +
                ::nom::sequence::preceded(
          90  +
                    ::nom::bytes::complete::tag("/"),
          91  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          92  +
                        ::nom::bytes::complete::take_until("/"),
          93  +
                        ::nom::combinator::rest,
          94  +
                    )),
          95  +
                ),
          96  +
            ))(input_string)?;
          97  +
        debug_assert_eq!("", input_string);
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          99  +
        input = input.set_string(
         100  +
            crate::protocol_serde::shape_http_request_with_labels_input::de_string(m1)?,
         101  +
        );
         102  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         103  +
        input = input
         104  +
            .set_short(crate::protocol_serde::shape_http_request_with_labels_input::de_short(m2)?);
         105  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         106  +
        input = input.set_integer(
         107  +
            crate::protocol_serde::shape_http_request_with_labels_input::de_integer(m3)?,
         108  +
        );
         109  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         110  +
        input = input
         111  +
            .set_long(crate::protocol_serde::shape_http_request_with_labels_input::de_long(m4)?);
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         113  +
        input = input
         114  +
            .set_float(crate::protocol_serde::shape_http_request_with_labels_input::de_float(m5)?);
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         116  +
        input = input.set_double(
         117  +
            crate::protocol_serde::shape_http_request_with_labels_input::de_double(m6)?,
         118  +
        );
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         120  +
        input = input.set_boolean(
         121  +
            crate::protocol_serde::shape_http_request_with_labels_input::de_boolean(m7)?,
         122  +
        );
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
         124  +
        input = input.set_timestamp(
         125  +
            crate::protocol_serde::shape_http_request_with_labels_input::de_timestamp(m8)?,
         126  +
        );
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
         128  +
        input.build()?
         129  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
         130  +
    })
         131  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
         132  +
}
         133  +
         134  +
/* RustType.kt:534 */
         135  +
#[allow(clippy::unnecessary_wraps)]
         136  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
         137  +
pub fn ser_http_request_with_labels_http_response(
         138  +
    #[allow(unused_variables)] output: crate::output::HttpRequestWithLabelsOutput,
         139  +
) -> std::result::Result<
         140  +
    ::aws_smithy_legacy_http_server::response::Response,
         141  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         142  +
> {
         143  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
         144  +
    Ok({
         145  +
        /* RustType.kt:534 */
         146  +
        #[allow(unused_mut)]
         147  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         148  +
        let mut builder = ::http::Response::builder();
         149  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
         150  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         151  +
            builder,
         152  +
            ::http::header::CONTENT_TYPE,
         153  +
            "application/json",
         154  +
        );
         155  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
         156  +
        let http_status: u16 = 200;
         157  +
        builder = builder.status(http_status);
         158  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         159  +
        let payload =
         160  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         161  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         162  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         163  +
        let content_length = payload.len();
         164  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         165  +
            builder,
         166  +
            ::http::header::CONTENT_LENGTH,
         167  +
            content_length,
         168  +
        );
         169  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         170  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         171  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         172  +
        builder.body(body)?
         173  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         174  +
    })
         175  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         176  +
}
         177  +
         178  +
/* RustType.kt:534 */
         179  +
#[allow(clippy::unnecessary_wraps)]
         180  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
         181  +
pub fn ser_http_request_with_labels_http_error(
         182  +
    error: &crate::error::HttpRequestWithLabelsError,
         183  +
) -> std::result::Result<
         184  +
    ::aws_smithy_legacy_http_server::response::Response,
         185  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         186  +
> {
         187  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         188  +
    Ok({
         189  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         190  +
        match error {
         191  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         192  +
            crate::error::HttpRequestWithLabelsError::ValidationException(output) => {
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         194  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         195  +
                /* RustType.kt:534 */
         196  +
                #[allow(unused_mut)]
         197  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         198  +
                let mut builder = ::http::Response::builder();
         199  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         200  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         201  +
                    builder,
         202  +
                    ::http::header::CONTENT_TYPE,
         203  +
                    "application/json",
         204  +
                );
         205  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         206  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         207  +
                    builder,
         208  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         209  +
                    "ValidationException",
         210  +
                );
         211  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         212  +
                let content_length = payload.len();
         213  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         214  +
                    builder,
         215  +
                    ::http::header::CONTENT_LENGTH,
         216  +
                    content_length,
         217  +
                );
         218  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         219  +
                builder
         220  +
                    .status(400)
         221  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         222  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         223  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         224  +
        }
         225  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         226  +
    })
         227  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         228  +
}