Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405

Files changed:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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