Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9

Files changed:

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

@@ -1,1 +14,20 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
    2      3   
pub(crate) fn de_payload_payload(
    3      4   
    body: &[u8],
    4      5   
) -> std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
    8     10   
    (!body.is_empty())
    9     11   
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:355 */
   10     13   
            let body_str = std::str::from_utf8(body)?;
          14  +
            /* HttpBindingGenerator.kt:367 */
   11     15   
            Ok(body_str.to_string())
          16  +
            /* HttpBindingGenerator.kt:342 */
   12     17   
        })
   13     18   
        .transpose()
          19  +
    /* HttpBindingGenerator.kt:254 */
   14     20   
}

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

@@ -1,1 +65,94 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_content_type_with_payload_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedContentTypeWithPayloadInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_content_type_with_payload_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   22     30   
        if let Some(value) = {
   23         -
            let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
            let bytes = {
          32  +
                use ::http_body_util::BodyExt;
          33  +
                body.collect().await?.to_bytes()
          34  +
            };
   24     35   
            if !bytes.is_empty() {
   25     36   
                ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   26     37   
                    &headers,
   27     38   
                    Some("image/jpeg"),
   28     39   
                )?;
   29     40   
            }
   30     41   
            crate::protocol_serde::shape_malformed_content_type_with_payload_input::de_payload_payload(&bytes)?
   31     42   
        } {
   32     43   
            input = input.set_payload(Some(value))
   33     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   34     46   
        input.build()
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   35     48   
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   36     50   
}
   37     51   
          52  +
/* RustType.kt:534 */
   38     53   
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   39     55   
pub fn ser_malformed_content_type_with_payload_http_response(
   40     56   
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithPayloadOutput,
   41     57   
) -> std::result::Result<
   42     58   
    ::aws_smithy_http_server::response::Response,
   43     59   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   44     60   
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   45     62   
    Ok({
          63  +
        /* RustType.kt:534 */
   46     64   
        #[allow(unused_mut)]
   47         -
        let mut builder = ::http::Response::builder();
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          66  +
        let mut builder = ::http_1x::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50         -
            ::http::header::CONTENT_TYPE,
          70  +
            ::http_1x::header::CONTENT_TYPE,
   51     71   
            "application/json",
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   53     74   
        let http_status: u16 = 200;
   54     75   
        builder = builder.status(http_status);
   55         -
        let payload = "";
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          77  +
        let payload =
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   56     81   
        let content_length = payload.len();
   57     82   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     83   
            builder,
   59         -
            ::http::header::CONTENT_LENGTH,
          84  +
            ::http_1x::header::CONTENT_LENGTH,
   60     85   
            content_length,
   61     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   62     88   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   63     90   
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   64     92   
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   65     94   
}

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

@@ -1,1 +11,18 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
    2      3   
pub(crate) fn de_payload_payload(
    3      4   
    body: &[u8],
    4      5   
) -> std::result::Result<
    5      6   
    ::std::option::Option<::aws_smithy_types::Blob>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
    8     10   
    (!body.is_empty())
    9         -
        .then(|| Ok(::aws_smithy_types::Blob::new(body)))
          11  +
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:372 */
          13  +
            Ok(::aws_smithy_types::Blob::new(body))
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
   10     16   
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
   11     18   
}

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

@@ -1,1 +54,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_content_type_without_body_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedContentTypeWithoutBodyInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_content_type_without_body_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:873 */
   22     30   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   23     32   
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   24     34   
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   25     36   
}
   26     37   
          38  +
/* RustType.kt:534 */
   27     39   
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   28     41   
pub fn ser_malformed_content_type_without_body_http_response(
   29     42   
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithoutBodyOutput,
   30     43   
) -> std::result::Result<
   31     44   
    ::aws_smithy_http_server::response::Response,
   32     45   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   33     46   
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   34     48   
    Ok({
          49  +
        /* RustType.kt:534 */
   35     50   
        #[allow(unused_mut)]
   36         -
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          52  +
        let mut builder = ::http_1x::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   37     54   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   38     55   
            builder,
   39         -
            ::http::header::CONTENT_TYPE,
          56  +
            ::http_1x::header::CONTENT_TYPE,
   40     57   
            "application/json",
   41     58   
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   42     60   
        let http_status: u16 = 200;
   43     61   
        builder = builder.status(http_status);
   44         -
        let payload = "";
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          63  +
        let payload =
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   45     67   
        let content_length = payload.len();
   46     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   47     69   
            builder,
   48         -
            ::http::header::CONTENT_LENGTH,
          70  +
            ::http_1x::header::CONTENT_LENGTH,
   49     71   
            content_length,
   50     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   51     74   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   52     76   
        builder.body(body)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   53     78   
    })
          79  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   54     80   
}

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

@@ -1,1 +58,84 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_content_type_without_body_empty_input_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedContentTypeWithoutBodyEmptyInputInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input =
   18     23   
            crate::input::malformed_content_type_without_body_empty_input_input::Builder::default();
          24  +
        /* RustType.kt:534 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   23     31   
        if let Some(value) = crate::protocol_serde::shape_malformed_content_type_without_body_empty_input_input::de_header_header(&headers)? {
   24     32   
                                input = input.set_header(Some(value))
   25     33   
                            }
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   26     35   
        input.build()
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   27     37   
    })
          38  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   28     39   
}
   29     40   
          41  +
/* RustType.kt:534 */
   30     42   
#[allow(clippy::unnecessary_wraps)]
          43  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   31     44   
pub fn ser_malformed_content_type_without_body_empty_input_http_response(
   32     45   
    #[allow(unused_variables)]
   33     46   
    output: crate::output::MalformedContentTypeWithoutBodyEmptyInputOutput,
   34     47   
) -> std::result::Result<
   35     48   
    ::aws_smithy_http_server::response::Response,
   36     49   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   37     50   
> {
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   38     52   
    Ok({
          53  +
        /* RustType.kt:534 */
   39     54   
        #[allow(unused_mut)]
   40         -
        let mut builder = ::http::Response::builder();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          56  +
        let mut builder = ::http_1x::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   41     58   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   42     59   
            builder,
   43         -
            ::http::header::CONTENT_TYPE,
          60  +
            ::http_1x::header::CONTENT_TYPE,
   44     61   
            "application/json",
   45     62   
        );
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   46     64   
        let http_status: u16 = 200;
   47     65   
        builder = builder.status(http_status);
   48         -
        let payload = "";
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          67  +
        let payload =
          68  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   49     71   
        let content_length = payload.len();
   50     72   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   51     73   
            builder,
   52         -
            ::http::header::CONTENT_LENGTH,
          74  +
            ::http_1x::header::CONTENT_LENGTH,
   53     75   
            content_length,
   54     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   55     78   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   56     80   
        builder.body(body)?
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   57     82   
    })
          83  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   58     84   
}

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

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

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

@@ -1,1 +187,262 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_double_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedDoubleInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_double_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_double::de_malformed_double(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   33     48   
        if let Some(value) =
   34     49   
            crate::protocol_serde::shape_malformed_double_input::de_double_in_header_header(
   35     50   
                &headers,
   36     51   
            )?
   37     52   
        {
   38     53   
            input = input.set_double_in_header(Some(value))
   39     54   
        }
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
   40     56   
        let input_string = uri.path();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   41     58   
        let (input_string, (_, m1)) =
   42     59   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   43     60   
                ::nom::sequence::preceded(
   44     61   
                    ::nom::bytes::complete::tag("/"),
   45     62   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   46     63   
                        "MalformedDouble",
   47     64   
                    ),
   48     65   
                ),
   49     66   
                ::nom::sequence::preceded(
   50     67   
                    ::nom::bytes::complete::tag("/"),
   51     68   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   52     69   
                        ::nom::bytes::complete::take_until("/"),
   53     70   
                        ::nom::combinator::rest,
   54     71   
                    )),
   55     72   
                ),
   56     73   
            ))(input_string)?;
   57     74   
        debug_assert_eq!("", input_string);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   58     76   
        input = input.set_double_in_path(
   59     77   
            crate::protocol_serde::shape_malformed_double_input::de_double_in_path(m1)?,
   60     78   
        );
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
   61     80   
        let query_string = uri.query().unwrap_or("");
   62     81   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
   63     83   
        let mut double_in_query_seen = false;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
   64     85   
        for (k, v) in pairs {
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
   65     87   
            if !double_in_query_seen && k == "doubleInQuery" {
   66     88   
                input = input.set_double_in_query(
   67     89   
                    crate::protocol_serde::shape_malformed_double_input::de_double_in_query(&v)?,
   68     90   
                );
   69     91   
                double_in_query_seen = true;
   70     92   
            }
          93  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
   71     94   
        }
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   72     96   
        input.build()?
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   73     98   
    })
          99  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   74    100   
}
   75    101   
         102  +
/* RustType.kt:534 */
   76    103   
#[allow(clippy::unnecessary_wraps)]
         104  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   77    105   
pub fn ser_malformed_double_http_response(
   78    106   
    #[allow(unused_variables)] output: crate::output::MalformedDoubleOutput,
   79    107   
) -> std::result::Result<
   80    108   
    ::aws_smithy_http_server::response::Response,
   81    109   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    110   
> {
         111  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   83    112   
    Ok({
         113  +
        /* RustType.kt:534 */
   84    114   
        #[allow(unused_mut)]
   85         -
        let mut builder = ::http::Response::builder();
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         116  +
        let mut builder = ::http_1x::Response::builder();
         117  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   86    118   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    119   
            builder,
   88         -
            ::http::header::CONTENT_TYPE,
         120  +
            ::http_1x::header::CONTENT_TYPE,
   89    121   
            "application/json",
   90    122   
        );
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   91    124   
        let http_status: u16 = 200;
   92    125   
        builder = builder.status(http_status);
   93         -
        let payload = "";
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         127  +
        let payload =
         128  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         129  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   94    131   
        let content_length = payload.len();
   95    132   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    133   
            builder,
   97         -
            ::http::header::CONTENT_LENGTH,
         134  +
            ::http_1x::header::CONTENT_LENGTH,
   98    135   
            content_length,
   99    136   
        );
         137  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
  100    138   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
  101    140   
        builder.body(body)?
         141  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
  102    142   
    })
         143  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
  103    144   
}
  104    145   
         146  +
/* RustType.kt:534 */
  105    147   
#[allow(clippy::unnecessary_wraps)]
         148  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
  106    149   
pub fn ser_malformed_double_http_error(
  107    150   
    error: &crate::error::MalformedDoubleError,
  108    151   
) -> std::result::Result<
  109    152   
    ::aws_smithy_http_server::response::Response,
  110    153   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  111    154   
> {
         155  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
  112    156   
    Ok({
         157  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
  113    158   
        match error {
         159  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
  114    160   
            crate::error::MalformedDoubleError::ValidationException(output) => {
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
  115    162   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         163  +
                /* RustType.kt:534 */
  116    164   
                #[allow(unused_mut)]
  117         -
                let mut builder = ::http::Response::builder();
         165  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         166  +
                let mut builder = ::http_1x::Response::builder();
         167  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  118    168   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  119    169   
                    builder,
  120         -
                    ::http::header::CONTENT_TYPE,
         170  +
                    ::http_1x::header::CONTENT_TYPE,
  121    171   
                    "application/json",
  122    172   
                );
         173  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  123    174   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    175   
                    builder,
  125         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         176  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
  126    177   
                    "ValidationException",
  127    178   
                );
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
  128    180   
                let content_length = payload.len();
  129    181   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    182   
                    builder,
  131         -
                    ::http::header::CONTENT_LENGTH,
         183  +
                    ::http_1x::header::CONTENT_LENGTH,
  132    184   
                    content_length,
  133    185   
                );
         186  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  134    187   
                builder
  135    188   
                    .status(400)
  136    189   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  137         -
            }
         190  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         191  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  138    192   
        }
         193  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  139    194   
    })
         195  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  140    196   
}
  141    197   
         198  +
/* JsonParserGenerator.kt:148 */
  142    199   
pub(crate) fn de_malformed_double(
  143    200   
    value: &[u8],
  144    201   
    mut builder: crate::input::malformed_double_input::Builder,
  145    202   
) -> ::std::result::Result<
  146    203   
    crate::input::malformed_double_input::Builder,
  147    204   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  148    205   
> {
         206  +
    /* JsonParserGenerator.kt:153 */
  149    207   
    let mut tokens_owned =
  150    208   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  151    209   
            .peekable();
  152    210   
    let tokens = &mut tokens_owned;
  153    211   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         212  +
    /* JsonParserGenerator.kt:684 */
  154    213   
    loop {
         214  +
        /* JsonParserGenerator.kt:685 */
  155    215   
        match tokens.next().transpose()? {
         216  +
            /* JsonParserGenerator.kt:686 */
  156    217   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  157    218   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         219  +
                /* JsonParserGenerator.kt:260 */
  158    220   
                match key.to_unescaped()?.as_ref() {
         221  +
                    /* JsonParserGenerator.kt:262 */
  159    222   
                    "doubleInBody" => {
         223  +
                        /* JsonParserGenerator.kt:272 */
  160    224   
                        builder = builder.set_double_in_body(
         225  +
                            /* JsonParserGenerator.kt:363 */
  161    226   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  162    227   
                                tokens.next(),
  163    228   
                            )?
  164         -
                            .map(|v| v.to_f64_lossy()),
         229  +
                            .map(|v| v.to_f64_lossy()), /* JsonParserGenerator.kt:272 */
  165    230   
                        );
         231  +
                        /* JsonParserGenerator.kt:262 */
  166    232   
                    }
  167         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         233  +
                    /* JsonParserGenerator.kt:290 */
         234  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  168    235   
                }
         236  +
                /* JsonParserGenerator.kt:686 */
  169    237   
            }
         238  +
            /* JsonParserGenerator.kt:695 */
  170    239   
            other => {
  171    240   
                return Err(
  172    241   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  173    242   
                        "expected object key or end object, found: {other:?}"
  174    243   
                    )),
  175    244   
                )
  176         -
            }
         245  +
            } /* JsonParserGenerator.kt:685 */
  177    246   
        }
         247  +
        /* JsonParserGenerator.kt:684 */
  178    248   
    }
         249  +
    /* JsonParserGenerator.kt:250 */
  179    250   
    if tokens.next().is_some() {
         251  +
        /* JsonParserGenerator.kt:251 */
  180    252   
        return Err(
  181    253   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  182    254   
                "found more JSON tokens after completing parsing",
  183    255   
            ),
  184    256   
        );
         257  +
        /* JsonParserGenerator.kt:250 */
  185    258   
    }
         259  +
    /* JsonParserGenerator.kt:163 */
  186    260   
    Ok(builder)
         261  +
    /* JsonParserGenerator.kt:148 */
  187    262   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_double_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<f64>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:166 */
    5      7   
    let headers = header_map.get_all("doubleInHeader");
           8  +
    /* HttpBindingGenerator.kt:427 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<f64>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:491 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:159 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   18     24   
pub fn de_double_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    f64,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   28     38   
pub fn de_double_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<f64>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   36     49   
}

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

@@ -1,1 +185,260 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_float_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedFloatInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_float_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_float::de_malformed_float(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   33     48   
        if let Some(value) =
   34     49   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_header_header(&headers)?
   35     50   
        {
   36     51   
            input = input.set_float_in_header(Some(value))
   37     52   
        }
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
   38     54   
        let input_string = uri.path();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   39     56   
        let (input_string, (_, m1)) =
   40     57   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     58   
                ::nom::sequence::preceded(
   42     59   
                    ::nom::bytes::complete::tag("/"),
   43     60   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   44     61   
                        "MalformedFloat",
   45     62   
                    ),
   46     63   
                ),
   47     64   
                ::nom::sequence::preceded(
   48     65   
                    ::nom::bytes::complete::tag("/"),
   49     66   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   50     67   
                        ::nom::bytes::complete::take_until("/"),
   51     68   
                        ::nom::combinator::rest,
   52     69   
                    )),
   53     70   
                ),
   54     71   
            ))(input_string)?;
   55     72   
        debug_assert_eq!("", input_string);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   56     74   
        input = input.set_float_in_path(
   57     75   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_path(m1)?,
   58     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
   59     78   
        let query_string = uri.query().unwrap_or("");
   60     79   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
   61     81   
        let mut float_in_query_seen = false;
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
   62     83   
        for (k, v) in pairs {
          84  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
   63     85   
            if !float_in_query_seen && k == "floatInQuery" {
   64     86   
                input = input.set_float_in_query(
   65     87   
                    crate::protocol_serde::shape_malformed_float_input::de_float_in_query(&v)?,
   66     88   
                );
   67     89   
                float_in_query_seen = true;
   68     90   
            }
          91  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
   69     92   
        }
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   70     94   
        input.build()?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   71     96   
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   72     98   
}
   73     99   
         100  +
/* RustType.kt:534 */
   74    101   
#[allow(clippy::unnecessary_wraps)]
         102  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   75    103   
pub fn ser_malformed_float_http_response(
   76    104   
    #[allow(unused_variables)] output: crate::output::MalformedFloatOutput,
   77    105   
) -> std::result::Result<
   78    106   
    ::aws_smithy_http_server::response::Response,
   79    107   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    108   
> {
         109  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   81    110   
    Ok({
         111  +
        /* RustType.kt:534 */
   82    112   
        #[allow(unused_mut)]
   83         -
        let mut builder = ::http::Response::builder();
         113  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         114  +
        let mut builder = ::http_1x::Response::builder();
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   84    116   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    117   
            builder,
   86         -
            ::http::header::CONTENT_TYPE,
         118  +
            ::http_1x::header::CONTENT_TYPE,
   87    119   
            "application/json",
   88    120   
        );
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   89    122   
        let http_status: u16 = 200;
   90    123   
        builder = builder.status(http_status);
   91         -
        let payload = "";
         124  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         125  +
        let payload =
         126  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         128  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   92    129   
        let content_length = payload.len();
   93    130   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    131   
            builder,
   95         -
            ::http::header::CONTENT_LENGTH,
         132  +
            ::http_1x::header::CONTENT_LENGTH,
   96    133   
            content_length,
   97    134   
        );
         135  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   98    136   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         137  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   99    138   
        builder.body(body)?
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
  100    140   
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
  101    142   
}
  102    143   
         144  +
/* RustType.kt:534 */
  103    145   
#[allow(clippy::unnecessary_wraps)]
         146  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
  104    147   
pub fn ser_malformed_float_http_error(
  105    148   
    error: &crate::error::MalformedFloatError,
  106    149   
) -> std::result::Result<
  107    150   
    ::aws_smithy_http_server::response::Response,
  108    151   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  109    152   
> {
         153  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
  110    154   
    Ok({
         155  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
  111    156   
        match error {
         157  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
  112    158   
            crate::error::MalformedFloatError::ValidationException(output) => {
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
  113    160   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         161  +
                /* RustType.kt:534 */
  114    162   
                #[allow(unused_mut)]
  115         -
                let mut builder = ::http::Response::builder();
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         164  +
                let mut builder = ::http_1x::Response::builder();
         165  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  116    166   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    167   
                    builder,
  118         -
                    ::http::header::CONTENT_TYPE,
         168  +
                    ::http_1x::header::CONTENT_TYPE,
  119    169   
                    "application/json",
  120    170   
                );
         171  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  121    172   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  122    173   
                    builder,
  123         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         174  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
  124    175   
                    "ValidationException",
  125    176   
                );
         177  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
  126    178   
                let content_length = payload.len();
  127    179   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  128    180   
                    builder,
  129         -
                    ::http::header::CONTENT_LENGTH,
         181  +
                    ::http_1x::header::CONTENT_LENGTH,
  130    182   
                    content_length,
  131    183   
                );
         184  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  132    185   
                builder
  133    186   
                    .status(400)
  134    187   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  135         -
            }
         188  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         189  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  136    190   
        }
         191  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  137    192   
    })
         193  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  138    194   
}
  139    195   
         196  +
/* JsonParserGenerator.kt:148 */
  140    197   
pub(crate) fn de_malformed_float(
  141    198   
    value: &[u8],
  142    199   
    mut builder: crate::input::malformed_float_input::Builder,
  143    200   
) -> ::std::result::Result<
  144    201   
    crate::input::malformed_float_input::Builder,
  145    202   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  146    203   
> {
         204  +
    /* JsonParserGenerator.kt:153 */
  147    205   
    let mut tokens_owned =
  148    206   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  149    207   
            .peekable();
  150    208   
    let tokens = &mut tokens_owned;
  151    209   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         210  +
    /* JsonParserGenerator.kt:684 */
  152    211   
    loop {
         212  +
        /* JsonParserGenerator.kt:685 */
  153    213   
        match tokens.next().transpose()? {
         214  +
            /* JsonParserGenerator.kt:686 */
  154    215   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  155    216   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         217  +
                /* JsonParserGenerator.kt:260 */
  156    218   
                match key.to_unescaped()?.as_ref() {
         219  +
                    /* JsonParserGenerator.kt:262 */
  157    220   
                    "floatInBody" => {
         221  +
                        /* JsonParserGenerator.kt:272 */
  158    222   
                        builder = builder.set_float_in_body(
         223  +
                            /* JsonParserGenerator.kt:361 */
  159    224   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  160    225   
                                tokens.next(),
  161    226   
                            )?
  162         -
                            .map(|v| v.to_f32_lossy()),
         227  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  163    228   
                        );
         229  +
                        /* JsonParserGenerator.kt:262 */
  164    230   
                    }
  165         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         231  +
                    /* JsonParserGenerator.kt:290 */
         232  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  166    233   
                }
         234  +
                /* JsonParserGenerator.kt:686 */
  167    235   
            }
         236  +
            /* JsonParserGenerator.kt:695 */
  168    237   
            other => {
  169    238   
                return Err(
  170    239   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  171    240   
                        "expected object key or end object, found: {other:?}"
  172    241   
                    )),
  173    242   
                )
  174         -
            }
         243  +
            } /* JsonParserGenerator.kt:685 */
  175    244   
        }
         245  +
        /* JsonParserGenerator.kt:684 */
  176    246   
    }
         247  +
    /* JsonParserGenerator.kt:250 */
  177    248   
    if tokens.next().is_some() {
         249  +
        /* JsonParserGenerator.kt:251 */
  178    250   
        return Err(
  179    251   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  180    252   
                "found more JSON tokens after completing parsing",
  181    253   
            ),
  182    254   
        );
         255  +
        /* JsonParserGenerator.kt:250 */
  183    256   
    }
         257  +
    /* JsonParserGenerator.kt:163 */
  184    258   
    Ok(builder)
         259  +
    /* JsonParserGenerator.kt:148 */
  185    260   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_float_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<f32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:166 */
    5      7   
    let headers = header_map.get_all("floatInHeader");
           8  +
    /* HttpBindingGenerator.kt:427 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<f32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:491 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:159 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   18     24   
pub fn de_float_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    f32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   28     38   
pub fn de_float_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<f32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   36     49   
}

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

@@ -1,1 +188,263 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_integer_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedIntegerInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_integer_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_integer::de_malformed_integer(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   33     48   
        if let Some(value) =
   34     49   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_header_header(
   35     50   
                &headers,
   36     51   
            )?
   37     52   
        {
   38     53   
            input = input.set_integer_in_header(Some(value))
   39     54   
        }
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
   40     56   
        let input_string = uri.path();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   41     58   
        let (input_string, (_, m1)) =
   42     59   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   43     60   
                ::nom::sequence::preceded(
   44     61   
                    ::nom::bytes::complete::tag("/"),
   45     62   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   46     63   
                        "MalformedInteger",
   47     64   
                    ),
   48     65   
                ),
   49     66   
                ::nom::sequence::preceded(
   50     67   
                    ::nom::bytes::complete::tag("/"),
   51     68   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   52     69   
                        ::nom::bytes::complete::take_until("/"),
   53     70   
                        ::nom::combinator::rest,
   54     71   
                    )),
   55     72   
                ),
   56     73   
            ))(input_string)?;
   57     74   
        debug_assert_eq!("", input_string);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   58     76   
        input = input.set_integer_in_path(
   59     77   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_path(m1)?,
   60     78   
        );
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
   61     80   
        let query_string = uri.query().unwrap_or("");
   62     81   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
   63     83   
        let mut integer_in_query_seen = false;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
   64     85   
        for (k, v) in pairs {
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
   65     87   
            if !integer_in_query_seen && k == "integerInQuery" {
   66     88   
                input = input.set_integer_in_query(
   67     89   
                    crate::protocol_serde::shape_malformed_integer_input::de_integer_in_query(&v)?,
   68     90   
                );
   69     91   
                integer_in_query_seen = true;
   70     92   
            }
          93  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
   71     94   
        }
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   72     96   
        input.build()?
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   73     98   
    })
          99  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   74    100   
}
   75    101   
         102  +
/* RustType.kt:534 */
   76    103   
#[allow(clippy::unnecessary_wraps)]
         104  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   77    105   
pub fn ser_malformed_integer_http_response(
   78    106   
    #[allow(unused_variables)] output: crate::output::MalformedIntegerOutput,
   79    107   
) -> std::result::Result<
   80    108   
    ::aws_smithy_http_server::response::Response,
   81    109   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    110   
> {
         111  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   83    112   
    Ok({
         113  +
        /* RustType.kt:534 */
   84    114   
        #[allow(unused_mut)]
   85         -
        let mut builder = ::http::Response::builder();
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         116  +
        let mut builder = ::http_1x::Response::builder();
         117  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   86    118   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    119   
            builder,
   88         -
            ::http::header::CONTENT_TYPE,
         120  +
            ::http_1x::header::CONTENT_TYPE,
   89    121   
            "application/json",
   90    122   
        );
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   91    124   
        let http_status: u16 = 200;
   92    125   
        builder = builder.status(http_status);
   93         -
        let payload = "";
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         127  +
        let payload =
         128  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         129  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   94    131   
        let content_length = payload.len();
   95    132   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    133   
            builder,
   97         -
            ::http::header::CONTENT_LENGTH,
         134  +
            ::http_1x::header::CONTENT_LENGTH,
   98    135   
            content_length,
   99    136   
        );
         137  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
  100    138   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
  101    140   
        builder.body(body)?
         141  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
  102    142   
    })
         143  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
  103    144   
}
  104    145   
         146  +
/* RustType.kt:534 */
  105    147   
#[allow(clippy::unnecessary_wraps)]
         148  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
  106    149   
pub fn ser_malformed_integer_http_error(
  107    150   
    error: &crate::error::MalformedIntegerError,
  108    151   
) -> std::result::Result<
  109    152   
    ::aws_smithy_http_server::response::Response,
  110    153   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  111    154   
> {
         155  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
  112    156   
    Ok({
         157  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
  113    158   
        match error {
         159  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
  114    160   
            crate::error::MalformedIntegerError::ValidationException(output) => {
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
  115    162   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         163  +
                /* RustType.kt:534 */
  116    164   
                #[allow(unused_mut)]
  117         -
                let mut builder = ::http::Response::builder();
         165  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         166  +
                let mut builder = ::http_1x::Response::builder();
         167  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  118    168   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  119    169   
                    builder,
  120         -
                    ::http::header::CONTENT_TYPE,
         170  +
                    ::http_1x::header::CONTENT_TYPE,
  121    171   
                    "application/json",
  122    172   
                );
         173  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  123    174   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    175   
                    builder,
  125         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         176  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
  126    177   
                    "ValidationException",
  127    178   
                );
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
  128    180   
                let content_length = payload.len();
  129    181   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    182   
                    builder,
  131         -
                    ::http::header::CONTENT_LENGTH,
         183  +
                    ::http_1x::header::CONTENT_LENGTH,
  132    184   
                    content_length,
  133    185   
                );
         186  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  134    187   
                builder
  135    188   
                    .status(400)
  136    189   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  137         -
            }
         190  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         191  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  138    192   
        }
         193  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  139    194   
    })
         195  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  140    196   
}
  141    197   
         198  +
/* JsonParserGenerator.kt:148 */
  142    199   
pub(crate) fn de_malformed_integer(
  143    200   
    value: &[u8],
  144    201   
    mut builder: crate::input::malformed_integer_input::Builder,
  145    202   
) -> ::std::result::Result<
  146    203   
    crate::input::malformed_integer_input::Builder,
  147    204   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  148    205   
> {
         206  +
    /* JsonParserGenerator.kt:153 */
  149    207   
    let mut tokens_owned =
  150    208   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  151    209   
            .peekable();
  152    210   
    let tokens = &mut tokens_owned;
  153    211   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         212  +
    /* JsonParserGenerator.kt:684 */
  154    213   
    loop {
         214  +
        /* JsonParserGenerator.kt:685 */
  155    215   
        match tokens.next().transpose()? {
         216  +
            /* JsonParserGenerator.kt:686 */
  156    217   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  157    218   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         219  +
                /* JsonParserGenerator.kt:260 */
  158    220   
                match key.to_unescaped()?.as_ref() {
         221  +
                    /* JsonParserGenerator.kt:262 */
  159    222   
                    "integerInBody" => {
         223  +
                        /* JsonParserGenerator.kt:272 */
  160    224   
                        builder = builder.set_integer_in_body(
         225  +
                            /* JsonParserGenerator.kt:365 */
  161    226   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  162    227   
                                tokens.next(),
  163    228   
                            )?
  164    229   
                            .map(i32::try_from)
  165         -
                            .transpose()?,
         230  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  166    231   
                        );
         232  +
                        /* JsonParserGenerator.kt:262 */
  167    233   
                    }
  168         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         234  +
                    /* JsonParserGenerator.kt:290 */
         235  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  169    236   
                }
         237  +
                /* JsonParserGenerator.kt:686 */
  170    238   
            }
         239  +
            /* JsonParserGenerator.kt:695 */
  171    240   
            other => {
  172    241   
                return Err(
  173    242   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  174    243   
                        "expected object key or end object, found: {other:?}"
  175    244   
                    )),
  176    245   
                )
  177         -
            }
         246  +
            } /* JsonParserGenerator.kt:685 */
  178    247   
        }
         248  +
        /* JsonParserGenerator.kt:684 */
  179    249   
    }
         250  +
    /* JsonParserGenerator.kt:250 */
  180    251   
    if tokens.next().is_some() {
         252  +
        /* JsonParserGenerator.kt:251 */
  181    253   
        return Err(
  182    254   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  183    255   
                "found more JSON tokens after completing parsing",
  184    256   
            ),
  185    257   
        );
         258  +
        /* JsonParserGenerator.kt:250 */
  186    259   
    }
         260  +
    /* JsonParserGenerator.kt:163 */
  187    261   
    Ok(builder)
         262  +
    /* JsonParserGenerator.kt:148 */
  188    263   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_integer_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:166 */
    5      7   
    let headers = header_map.get_all("integerInHeader");
           8  +
    /* HttpBindingGenerator.kt:427 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:491 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:159 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   18     24   
pub fn de_integer_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   28     38   
pub fn de_integer_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   36     49   
}

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

@@ -1,1 +108,158 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_list_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedListInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_list_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_list::de_malformed_list(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   33     48   
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   34     50   
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   35     52   
}
   36     53   
          54  +
/* RustType.kt:534 */
   37     55   
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   38     57   
pub fn ser_malformed_list_http_response(
   39     58   
    #[allow(unused_variables)] output: crate::output::MalformedListOutput,
   40     59   
) -> std::result::Result<
   41     60   
    ::aws_smithy_http_server::response::Response,
   42     61   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     62   
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   44     64   
    Ok({
          65  +
        /* RustType.kt:534 */
   45     66   
        #[allow(unused_mut)]
   46         -
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          68  +
        let mut builder = ::http_1x::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   47     70   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     71   
            builder,
   49         -
            ::http::header::CONTENT_TYPE,
          72  +
            ::http_1x::header::CONTENT_TYPE,
   50     73   
            "application/json",
   51     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   52     76   
        let http_status: u16 = 200;
   53     77   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          79  +
        let payload =
          80  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   55     83   
        let content_length = payload.len();
   56     84   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     85   
            builder,
   58         -
            ::http::header::CONTENT_LENGTH,
          86  +
            ::http_1x::header::CONTENT_LENGTH,
   59     87   
            content_length,
   60     88   
        );
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   61     90   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   62     92   
        builder.body(body)?
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   63     94   
    })
          95  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   64     96   
}
   65     97   
          98  +
/* JsonParserGenerator.kt:148 */
   66     99   
pub(crate) fn de_malformed_list(
   67    100   
    value: &[u8],
   68    101   
    mut builder: crate::input::malformed_list_input::Builder,
   69    102   
) -> ::std::result::Result<
   70    103   
    crate::input::malformed_list_input::Builder,
   71    104   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   72    105   
> {
         106  +
    /* JsonParserGenerator.kt:153 */
   73    107   
    let mut tokens_owned =
   74    108   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   75    109   
            .peekable();
   76    110   
    let tokens = &mut tokens_owned;
   77    111   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         112  +
    /* JsonParserGenerator.kt:684 */
   78    113   
    loop {
         114  +
        /* JsonParserGenerator.kt:685 */
   79    115   
        match tokens.next().transpose()? {
         116  +
            /* JsonParserGenerator.kt:686 */
   80    117   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   81    118   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                /* JsonParserGenerator.kt:260 */
   82    120   
                match key.to_unescaped()?.as_ref() {
         121  +
                    /* JsonParserGenerator.kt:262 */
   83    122   
                    "bodyList" => {
         123  +
                        /* JsonParserGenerator.kt:272 */
   84    124   
                        builder = builder.set_body_list(
   85         -
                            crate::protocol_serde::shape_simple_list::de_simple_list(tokens)?,
   86         -
                        );
         125  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_simple_list::de_simple_list(tokens)?
         126  +
                        /* JsonParserGenerator.kt:272 */);
         127  +
                        /* JsonParserGenerator.kt:262 */
   87    128   
                    }
   88         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         129  +
                    /* JsonParserGenerator.kt:290 */
         130  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   89    131   
                }
         132  +
                /* JsonParserGenerator.kt:686 */
   90    133   
            }
         134  +
            /* JsonParserGenerator.kt:695 */
   91    135   
            other => {
   92    136   
                return Err(
   93    137   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   94    138   
                        "expected object key or end object, found: {other:?}"
   95    139   
                    )),
   96    140   
                )
   97         -
            }
         141  +
            } /* JsonParserGenerator.kt:685 */
   98    142   
        }
         143  +
        /* JsonParserGenerator.kt:684 */
   99    144   
    }
         145  +
    /* JsonParserGenerator.kt:250 */
  100    146   
    if tokens.next().is_some() {
         147  +
        /* JsonParserGenerator.kt:251 */
  101    148   
        return Err(
  102    149   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  103    150   
                "found more JSON tokens after completing parsing",
  104    151   
            ),
  105    152   
        );
         153  +
        /* JsonParserGenerator.kt:250 */
  106    154   
    }
         155  +
    /* JsonParserGenerator.kt:163 */
  107    156   
    Ok(builder)
         157  +
    /* JsonParserGenerator.kt:148 */
  108    158   
}

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

@@ -1,1 +184,259 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_long_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedLongInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_long_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_long::de_malformed_long(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   33     48   
        if let Some(value) =
   34     49   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_header_header(&headers)?
   35     50   
        {
   36     51   
            input = input.set_long_in_header(Some(value))
   37     52   
        }
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
   38     54   
        let input_string = uri.path();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   39     56   
        let (input_string, (_, m1)) =
   40     57   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     58   
                ::nom::sequence::preceded(
   42     59   
                    ::nom::bytes::complete::tag("/"),
   43     60   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("MalformedLong"),
   44     61   
                ),
   45     62   
                ::nom::sequence::preceded(
   46     63   
                    ::nom::bytes::complete::tag("/"),
   47     64   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   48     65   
                        ::nom::bytes::complete::take_until("/"),
   49     66   
                        ::nom::combinator::rest,
   50     67   
                    )),
   51     68   
                ),
   52     69   
            ))(input_string)?;
   53     70   
        debug_assert_eq!("", input_string);
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   54     72   
        input = input.set_long_in_path(
   55     73   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_path(m1)?,
   56     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
   57     76   
        let query_string = uri.query().unwrap_or("");
   58     77   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
   59     79   
        let mut long_in_query_seen = false;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
   60     81   
        for (k, v) in pairs {
          82  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
   61     83   
            if !long_in_query_seen && k == "longInQuery" {
   62     84   
                input = input.set_long_in_query(
   63     85   
                    crate::protocol_serde::shape_malformed_long_input::de_long_in_query(&v)?,
   64     86   
                );
   65     87   
                long_in_query_seen = true;
   66     88   
            }
          89  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
   67     90   
        }
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   68     92   
        input.build()?
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   69     94   
    })
          95  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   70     96   
}
   71     97   
          98  +
/* RustType.kt:534 */
   72     99   
#[allow(clippy::unnecessary_wraps)]
         100  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   73    101   
pub fn ser_malformed_long_http_response(
   74    102   
    #[allow(unused_variables)] output: crate::output::MalformedLongOutput,
   75    103   
) -> std::result::Result<
   76    104   
    ::aws_smithy_http_server::response::Response,
   77    105   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   78    106   
> {
         107  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   79    108   
    Ok({
         109  +
        /* RustType.kt:534 */
   80    110   
        #[allow(unused_mut)]
   81         -
        let mut builder = ::http::Response::builder();
         111  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         112  +
        let mut builder = ::http_1x::Response::builder();
         113  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   82    114   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    115   
            builder,
   84         -
            ::http::header::CONTENT_TYPE,
         116  +
            ::http_1x::header::CONTENT_TYPE,
   85    117   
            "application/json",
   86    118   
        );
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   87    120   
        let http_status: u16 = 200;
   88    121   
        builder = builder.status(http_status);
   89         -
        let payload = "";
         122  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         123  +
        let payload =
         124  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         125  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   90    127   
        let content_length = payload.len();
   91    128   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   92    129   
            builder,
   93         -
            ::http::header::CONTENT_LENGTH,
         130  +
            ::http_1x::header::CONTENT_LENGTH,
   94    131   
            content_length,
   95    132   
        );
         133  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   96    134   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         135  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   97    136   
        builder.body(body)?
         137  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   98    138   
    })
         139  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   99    140   
}
  100    141   
         142  +
/* RustType.kt:534 */
  101    143   
#[allow(clippy::unnecessary_wraps)]
         144  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
  102    145   
pub fn ser_malformed_long_http_error(
  103    146   
    error: &crate::error::MalformedLongError,
  104    147   
) -> std::result::Result<
  105    148   
    ::aws_smithy_http_server::response::Response,
  106    149   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  107    150   
> {
         151  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
  108    152   
    Ok({
         153  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
  109    154   
        match error {
         155  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
  110    156   
            crate::error::MalformedLongError::ValidationException(output) => {
         157  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
  111    158   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         159  +
                /* RustType.kt:534 */
  112    160   
                #[allow(unused_mut)]
  113         -
                let mut builder = ::http::Response::builder();
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         162  +
                let mut builder = ::http_1x::Response::builder();
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  114    164   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  115    165   
                    builder,
  116         -
                    ::http::header::CONTENT_TYPE,
         166  +
                    ::http_1x::header::CONTENT_TYPE,
  117    167   
                    "application/json",
  118    168   
                );
         169  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  119    170   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  120    171   
                    builder,
  121         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         172  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
  122    173   
                    "ValidationException",
  123    174   
                );
         175  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
  124    176   
                let content_length = payload.len();
  125    177   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  126    178   
                    builder,
  127         -
                    ::http::header::CONTENT_LENGTH,
         179  +
                    ::http_1x::header::CONTENT_LENGTH,
  128    180   
                    content_length,
  129    181   
                );
         182  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  130    183   
                builder
  131    184   
                    .status(400)
  132    185   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  133         -
            }
         186  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         187  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  134    188   
        }
         189  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  135    190   
    })
         191  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  136    192   
}
  137    193   
         194  +
/* JsonParserGenerator.kt:148 */
  138    195   
pub(crate) fn de_malformed_long(
  139    196   
    value: &[u8],
  140    197   
    mut builder: crate::input::malformed_long_input::Builder,
  141    198   
) -> ::std::result::Result<
  142    199   
    crate::input::malformed_long_input::Builder,
  143    200   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  144    201   
> {
         202  +
    /* JsonParserGenerator.kt:153 */
  145    203   
    let mut tokens_owned =
  146    204   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  147    205   
            .peekable();
  148    206   
    let tokens = &mut tokens_owned;
  149    207   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         208  +
    /* JsonParserGenerator.kt:684 */
  150    209   
    loop {
         210  +
        /* JsonParserGenerator.kt:685 */
  151    211   
        match tokens.next().transpose()? {
         212  +
            /* JsonParserGenerator.kt:686 */
  152    213   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  153    214   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         215  +
                /* JsonParserGenerator.kt:260 */
  154    216   
                match key.to_unescaped()?.as_ref() {
         217  +
                    /* JsonParserGenerator.kt:262 */
  155    218   
                    "longInBody" => {
         219  +
                        /* JsonParserGenerator.kt:272 */
  156    220   
                        builder = builder.set_long_in_body(
         221  +
                            /* JsonParserGenerator.kt:365 */
  157    222   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  158    223   
                                tokens.next(),
  159    224   
                            )?
  160    225   
                            .map(i64::try_from)
  161         -
                            .transpose()?,
         226  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  162    227   
                        );
         228  +
                        /* JsonParserGenerator.kt:262 */
  163    229   
                    }
  164         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         230  +
                    /* JsonParserGenerator.kt:290 */
         231  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  165    232   
                }
         233  +
                /* JsonParserGenerator.kt:686 */
  166    234   
            }
         235  +
            /* JsonParserGenerator.kt:695 */
  167    236   
            other => {
  168    237   
                return Err(
  169    238   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  170    239   
                        "expected object key or end object, found: {other:?}"
  171    240   
                    )),
  172    241   
                )
  173         -
            }
         242  +
            } /* JsonParserGenerator.kt:685 */
  174    243   
        }
         244  +
        /* JsonParserGenerator.kt:684 */
  175    245   
    }
         246  +
    /* JsonParserGenerator.kt:250 */
  176    247   
    if tokens.next().is_some() {
         248  +
        /* JsonParserGenerator.kt:251 */
  177    249   
        return Err(
  178    250   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  179    251   
                "found more JSON tokens after completing parsing",
  180    252   
            ),
  181    253   
        );
         254  +
        /* JsonParserGenerator.kt:250 */
  182    255   
    }
         256  +
    /* JsonParserGenerator.kt:163 */
  183    257   
    Ok(builder)
         258  +
    /* JsonParserGenerator.kt:148 */
  184    259   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_long_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i64>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:166 */
    5      7   
    let headers = header_map.get_all("longInHeader");
           8  +
    /* HttpBindingGenerator.kt:427 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i64>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:491 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:159 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   18     24   
pub fn de_long_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i64,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   28     38   
pub fn de_long_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i64>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   36     49   
}

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

@@ -1,1 +108,158 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_map_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedMapInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_map_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_map::de_malformed_map(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   33     48   
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   34     50   
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   35     52   
}
   36     53   
          54  +
/* RustType.kt:534 */
   37     55   
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   38     57   
pub fn ser_malformed_map_http_response(
   39     58   
    #[allow(unused_variables)] output: crate::output::MalformedMapOutput,
   40     59   
) -> std::result::Result<
   41     60   
    ::aws_smithy_http_server::response::Response,
   42     61   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     62   
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   44     64   
    Ok({
          65  +
        /* RustType.kt:534 */
   45     66   
        #[allow(unused_mut)]
   46         -
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          68  +
        let mut builder = ::http_1x::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   47     70   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     71   
            builder,
   49         -
            ::http::header::CONTENT_TYPE,
          72  +
            ::http_1x::header::CONTENT_TYPE,
   50     73   
            "application/json",
   51     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   52     76   
        let http_status: u16 = 200;
   53     77   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          79  +
        let payload =
          80  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   55     83   
        let content_length = payload.len();
   56     84   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     85   
            builder,
   58         -
            ::http::header::CONTENT_LENGTH,
          86  +
            ::http_1x::header::CONTENT_LENGTH,
   59     87   
            content_length,
   60     88   
        );
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   61     90   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   62     92   
        builder.body(body)?
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   63     94   
    })
          95  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   64     96   
}
   65     97   
          98  +
/* JsonParserGenerator.kt:148 */
   66     99   
pub(crate) fn de_malformed_map(
   67    100   
    value: &[u8],
   68    101   
    mut builder: crate::input::malformed_map_input::Builder,
   69    102   
) -> ::std::result::Result<
   70    103   
    crate::input::malformed_map_input::Builder,
   71    104   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   72    105   
> {
         106  +
    /* JsonParserGenerator.kt:153 */
   73    107   
    let mut tokens_owned =
   74    108   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   75    109   
            .peekable();
   76    110   
    let tokens = &mut tokens_owned;
   77    111   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         112  +
    /* JsonParserGenerator.kt:684 */
   78    113   
    loop {
         114  +
        /* JsonParserGenerator.kt:685 */
   79    115   
        match tokens.next().transpose()? {
         116  +
            /* JsonParserGenerator.kt:686 */
   80    117   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   81    118   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                /* JsonParserGenerator.kt:260 */
   82    120   
                match key.to_unescaped()?.as_ref() {
         121  +
                    /* JsonParserGenerator.kt:262 */
   83    122   
                    "bodyMap" => {
         123  +
                        /* JsonParserGenerator.kt:272 */
   84    124   
                        builder = builder.set_body_map(
   85         -
                            crate::protocol_serde::shape_simple_map::de_simple_map(tokens)?,
   86         -
                        );
         125  +
                            /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_simple_map::de_simple_map(tokens)?
         126  +
                        /* JsonParserGenerator.kt:272 */);
         127  +
                        /* JsonParserGenerator.kt:262 */
   87    128   
                    }
   88         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         129  +
                    /* JsonParserGenerator.kt:290 */
         130  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   89    131   
                }
         132  +
                /* JsonParserGenerator.kt:686 */
   90    133   
            }
         134  +
            /* JsonParserGenerator.kt:695 */
   91    135   
            other => {
   92    136   
                return Err(
   93    137   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   94    138   
                        "expected object key or end object, found: {other:?}"
   95    139   
                    )),
   96    140   
                )
   97         -
            }
         141  +
            } /* JsonParserGenerator.kt:685 */
   98    142   
        }
         143  +
        /* JsonParserGenerator.kt:684 */
   99    144   
    }
         145  +
    /* JsonParserGenerator.kt:250 */
  100    146   
    if tokens.next().is_some() {
         147  +
        /* JsonParserGenerator.kt:251 */
  101    148   
        return Err(
  102    149   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  103    150   
                "found more JSON tokens after completing parsing",
  104    151   
            ),
  105    152   
        );
         153  +
        /* JsonParserGenerator.kt:250 */
  106    154   
    }
         155  +
    /* JsonParserGenerator.kt:163 */
  107    156   
    Ok(builder)
         157  +
    /* JsonParserGenerator.kt:148 */
  108    158   
}