Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9

Files changed:

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

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

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

@@ -0,1 +0,158 @@
           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_blob_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedBlobInput,
           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_blob_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_blob::de_malformed_blob(
          39  +
                bytes.as_ref(),
          40  +
                input,
          41  +
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          45  +
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          47  +
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          49  +
}
          50  +
          51  +
/* RustType.kt:534 */
          52  +
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          54  +
pub fn ser_malformed_blob_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::MalformedBlobOutput,
          56  +
) -> std::result::Result<
          57  +
    ::aws_smithy_legacy_http_server::response::Response,
          58  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          59  +
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          61  +
    Ok({
          62  +
        /* RustType.kt:534 */
          63  +
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          67  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          68  +
            builder,
          69  +
            ::http::header::CONTENT_TYPE,
          70  +
            "application/json",
          71  +
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          73  +
        let http_status: u16 = 200;
          74  +
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          80  +
        let content_length = payload.len();
          81  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
            builder,
          83  +
            ::http::header::CONTENT_LENGTH,
          84  +
            content_length,
          85  +
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          87  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          89  +
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          91  +
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          93  +
}
          94  +
          95  +
/* JsonParserGenerator.kt:148 */
          96  +
pub(crate) fn de_malformed_blob(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::malformed_blob_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::malformed_blob_input::Builder,
         101  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         102  +
> {
         103  +
    /* JsonParserGenerator.kt:153 */
         104  +
    let mut tokens_owned =
         105  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         106  +
            .peekable();
         107  +
    let tokens = &mut tokens_owned;
         108  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         109  +
    /* JsonParserGenerator.kt:684 */
         110  +
    loop {
         111  +
        /* JsonParserGenerator.kt:685 */
         112  +
        match tokens.next().transpose()? {
         113  +
            /* JsonParserGenerator.kt:686 */
         114  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         115  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                /* JsonParserGenerator.kt:260 */
         117  +
                match key.to_unescaped()?.as_ref() {
         118  +
                    /* JsonParserGenerator.kt:262 */
         119  +
                    "blob" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_blob(
         122  +
                            /* JsonParserGenerator.kt:326 */
         123  +
                            ::aws_smithy_json::deserialize::token::expect_blob_or_null(
         124  +
                                tokens.next(),
         125  +
                            )?, /* JsonParserGenerator.kt:272 */
         126  +
                        );
         127  +
                        /* JsonParserGenerator.kt:262 */
         128  +
                    }
         129  +
                    /* JsonParserGenerator.kt:290 */
         130  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         131  +
                }
         132  +
                /* JsonParserGenerator.kt:686 */
         133  +
            }
         134  +
            /* JsonParserGenerator.kt:695 */
         135  +
            other => {
         136  +
                return Err(
         137  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         138  +
                        "expected object key or end object, found: {other:?}"
         139  +
                    )),
         140  +
                )
         141  +
            } /* JsonParserGenerator.kt:685 */
         142  +
        }
         143  +
        /* JsonParserGenerator.kt:684 */
         144  +
    }
         145  +
    /* JsonParserGenerator.kt:250 */
         146  +
    if tokens.next().is_some() {
         147  +
        /* JsonParserGenerator.kt:251 */
         148  +
        return Err(
         149  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         150  +
                "found more JSON tokens after completing parsing",
         151  +
            ),
         152  +
        );
         153  +
        /* JsonParserGenerator.kt:250 */
         154  +
    }
         155  +
    /* JsonParserGenerator.kt:163 */
         156  +
    Ok(builder)
         157  +
    /* JsonParserGenerator.kt:148 */
         158  +
}

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

@@ -0,1 +0,258 @@
           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_boolean_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedBooleanInput,
           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_boolean_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_boolean::de_malformed_boolean(
          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_boolean_input::de_boolean_in_header_header(
          47  +
                &headers,
          48  +
            )?
          49  +
        {
          50  +
            input = input.set_boolean_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  +
                        "MalformedBoolean",
          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_boolean_in_path(
          74  +
            crate::protocol_serde::shape_malformed_boolean_input::de_boolean_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 boolean_in_query_seen = false;
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          82  +
        for (k, v) in pairs {
          83  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          84  +
            if !boolean_in_query_seen && k == "booleanInQuery" {
          85  +
                input = input.set_boolean_in_query(
          86  +
                    crate::protocol_serde::shape_malformed_boolean_input::de_boolean_in_query(&v)?,
          87  +
                );
          88  +
                boolean_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_boolean_http_response(
         103  +
    #[allow(unused_variables)] output: crate::output::MalformedBooleanOutput,
         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_boolean_http_error(
         147  +
    error: &crate::error::MalformedBooleanError,
         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::MalformedBooleanError::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_boolean(
         197  +
    value: &[u8],
         198  +
    mut builder: crate::input::malformed_boolean_input::Builder,
         199  +
) -> ::std::result::Result<
         200  +
    crate::input::malformed_boolean_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  +
                    "booleanInBody" => {
         220  +
                        /* JsonParserGenerator.kt:272 */
         221  +
                        builder = builder.set_boolean_in_body(
         222  +
                            /* JsonParserGenerator.kt:298 */
         223  +
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
         224  +
                                tokens.next(),
         225  +
                            )?, /* JsonParserGenerator.kt:272 */
         226  +
                        );
         227  +
                        /* JsonParserGenerator.kt:262 */
         228  +
                    }
         229  +
                    /* JsonParserGenerator.kt:290 */
         230  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         231  +
                }
         232  +
                /* JsonParserGenerator.kt:686 */
         233  +
            }
         234  +
            /* JsonParserGenerator.kt:695 */
         235  +
            other => {
         236  +
                return Err(
         237  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         238  +
                        "expected object key or end object, found: {other:?}"
         239  +
                    )),
         240  +
                )
         241  +
            } /* JsonParserGenerator.kt:685 */
         242  +
        }
         243  +
        /* JsonParserGenerator.kt:684 */
         244  +
    }
         245  +
    /* JsonParserGenerator.kt:250 */
         246  +
    if tokens.next().is_some() {
         247  +
        /* JsonParserGenerator.kt:251 */
         248  +
        return Err(
         249  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         250  +
                "found more JSON tokens after completing parsing",
         251  +
            ),
         252  +
        );
         253  +
        /* JsonParserGenerator.kt:250 */
         254  +
    }
         255  +
    /* JsonParserGenerator.kt:163 */
         256  +
    Ok(builder)
         257  +
    /* JsonParserGenerator.kt:148 */
         258  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_boolean_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_boolean_in_header_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<::std::option::Option<bool>, ::aws_smithy_legacy_http::header::ParseError>
           6  +
{
           7  +
    /* HttpBindingGenerator.kt:166 */
           8  +
    let headers = header_map.get_all("booleanInHeader");
           9  +
    /* HttpBindingGenerator.kt:427 */
          10  +
    let var_1 = ::aws_smithy_legacy_http::header::read_many_primitive::<bool>(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_boolean_in_path(
          26  +
    value: &str,
          27  +
) -> std::result::Result<
          28  +
    bool,
          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_boolean_in_query(
          40  +
    value: &str,
          41  +
) -> std::result::Result<
          42  +
    ::std::option::Option<bool>,
          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_byte.rs

@@ -0,1 +0,256 @@
           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_byte_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedByteInput,
           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_byte_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_byte::de_malformed_byte(
          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_byte_input::de_byte_in_header_header(&headers)?
          47  +
        {
          48  +
            input = input.set_byte_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>>("MalformedByte"),
          58  +
                ),
          59  +
                ::nom::sequence::preceded(
          60  +
                    ::nom::bytes::complete::tag("/"),
          61  +
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
          62  +
                        ::nom::bytes::complete::take_until("/"),
          63  +
                        ::nom::combinator::rest,
          64  +
                    )),
          65  +
                ),
          66  +
            ))(input_string)?;
          67  +
        debug_assert_eq!("", input_string);
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
          69  +
        input = input.set_byte_in_path(
          70  +
            crate::protocol_serde::shape_malformed_byte_input::de_byte_in_path(m1)?,
          71  +
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
          73  +
        let query_string = uri.query().unwrap_or("");
          74  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
          76  +
        let mut byte_in_query_seen = false;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          78  +
        for (k, v) in pairs {
          79  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          80  +
            if !byte_in_query_seen && k == "byteInQuery" {
          81  +
                input = input.set_byte_in_query(
          82  +
                    crate::protocol_serde::shape_malformed_byte_input::de_byte_in_query(&v)?,
          83  +
                );
          84  +
                byte_in_query_seen = true;
          85  +
            }
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
          87  +
        }
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          89  +
        input.build()?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          91  +
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          93  +
}
          94  +
          95  +
/* RustType.kt:534 */
          96  +
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          98  +
pub fn ser_malformed_byte_http_response(
          99  +
    #[allow(unused_variables)] output: crate::output::MalformedByteOutput,
         100  +
) -> std::result::Result<
         101  +
    ::aws_smithy_legacy_http_server::response::Response,
         102  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         103  +
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
         105  +
    Ok({
         106  +
        /* RustType.kt:534 */
         107  +
        #[allow(unused_mut)]
         108  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         109  +
        let mut builder = ::http::Response::builder();
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
         111  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         112  +
            builder,
         113  +
            ::http::header::CONTENT_TYPE,
         114  +
            "application/json",
         115  +
        );
         116  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
         117  +
        let http_status: u16 = 200;
         118  +
        builder = builder.status(http_status);
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         120  +
        let payload =
         121  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         122  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         124  +
        let content_length = payload.len();
         125  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         126  +
            builder,
         127  +
            ::http::header::CONTENT_LENGTH,
         128  +
            content_length,
         129  +
        );
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         131  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         133  +
        builder.body(body)?
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         135  +
    })
         136  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         137  +
}
         138  +
         139  +
/* RustType.kt:534 */
         140  +
#[allow(clippy::unnecessary_wraps)]
         141  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
         142  +
pub fn ser_malformed_byte_http_error(
         143  +
    error: &crate::error::MalformedByteError,
         144  +
) -> std::result::Result<
         145  +
    ::aws_smithy_legacy_http_server::response::Response,
         146  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         147  +
> {
         148  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         149  +
    Ok({
         150  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         151  +
        match error {
         152  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         153  +
            crate::error::MalformedByteError::ValidationException(output) => {
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         155  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         156  +
                /* RustType.kt:534 */
         157  +
                #[allow(unused_mut)]
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         159  +
                let mut builder = ::http::Response::builder();
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         161  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         162  +
                    builder,
         163  +
                    ::http::header::CONTENT_TYPE,
         164  +
                    "application/json",
         165  +
                );
         166  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         167  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         168  +
                    builder,
         169  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         170  +
                    "ValidationException",
         171  +
                );
         172  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         173  +
                let content_length = payload.len();
         174  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         175  +
                    builder,
         176  +
                    ::http::header::CONTENT_LENGTH,
         177  +
                    content_length,
         178  +
                );
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         180  +
                builder
         181  +
                    .status(400)
         182  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         184  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         185  +
        }
         186  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         187  +
    })
         188  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         189  +
}
         190  +
         191  +
/* JsonParserGenerator.kt:148 */
         192  +
pub(crate) fn de_malformed_byte(
         193  +
    value: &[u8],
         194  +
    mut builder: crate::input::malformed_byte_input::Builder,
         195  +
) -> ::std::result::Result<
         196  +
    crate::input::malformed_byte_input::Builder,
         197  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         198  +
> {
         199  +
    /* JsonParserGenerator.kt:153 */
         200  +
    let mut tokens_owned =
         201  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         202  +
            .peekable();
         203  +
    let tokens = &mut tokens_owned;
         204  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         205  +
    /* JsonParserGenerator.kt:684 */
         206  +
    loop {
         207  +
        /* JsonParserGenerator.kt:685 */
         208  +
        match tokens.next().transpose()? {
         209  +
            /* JsonParserGenerator.kt:686 */
         210  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         211  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         212  +
                /* JsonParserGenerator.kt:260 */
         213  +
                match key.to_unescaped()?.as_ref() {
         214  +
                    /* JsonParserGenerator.kt:262 */
         215  +
                    "byteInBody" => {
         216  +
                        /* JsonParserGenerator.kt:272 */
         217  +
                        builder = builder.set_byte_in_body(
         218  +
                            /* JsonParserGenerator.kt:365 */
         219  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         220  +
                                tokens.next(),
         221  +
                            )?
         222  +
                            .map(i8::try_from)
         223  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         224  +
                        );
         225  +
                        /* JsonParserGenerator.kt:262 */
         226  +
                    }
         227  +
                    /* JsonParserGenerator.kt:290 */
         228  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         229  +
                }
         230  +
                /* JsonParserGenerator.kt:686 */
         231  +
            }
         232  +
            /* JsonParserGenerator.kt:695 */
         233  +
            other => {
         234  +
                return Err(
         235  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         236  +
                        "expected object key or end object, found: {other:?}"
         237  +
                    )),
         238  +
                )
         239  +
            } /* JsonParserGenerator.kt:685 */
         240  +
        }
         241  +
        /* JsonParserGenerator.kt:684 */
         242  +
    }
         243  +
    /* JsonParserGenerator.kt:250 */
         244  +
    if tokens.next().is_some() {
         245  +
        /* JsonParserGenerator.kt:251 */
         246  +
        return Err(
         247  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         248  +
                "found more JSON tokens after completing parsing",
         249  +
            ),
         250  +
        );
         251  +
        /* JsonParserGenerator.kt:250 */
         252  +
    }
         253  +
    /* JsonParserGenerator.kt:163 */
         254  +
    Ok(builder)
         255  +
    /* JsonParserGenerator.kt:148 */
         256  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_byte_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_byte_in_header_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<::std::option::Option<i8>, ::aws_smithy_legacy_http::header::ParseError>
           6  +
{
           7  +
    /* HttpBindingGenerator.kt:166 */
           8  +
    let headers = header_map.get_all("byteInHeader");
           9  +
    /* HttpBindingGenerator.kt:427 */
          10  +
    let var_1 = ::aws_smithy_legacy_http::header::read_many_primitive::<i8>(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_byte_in_path(
          26  +
    value: &str,
          27  +
) -> std::result::Result<
          28  +
    i8,
          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_byte_in_query(
          40  +
    value: &str,
          41  +
) -> std::result::Result<
          42  +
    ::std::option::Option<i8>,
          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_content_type_with_body.rs

@@ -0,1 +0,160 @@
           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_body_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedContentTypeWithBodyInput,
           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_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: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_content_type_with_body::de_malformed_content_type_with_body(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          40  +
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          42  +
        input.build()
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          44  +
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          46  +
}
          47  +
          48  +
/* RustType.kt:534 */
          49  +
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          51  +
pub fn ser_malformed_content_type_with_body_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithBodyOutput,
          53  +
) -> std::result::Result<
          54  +
    ::aws_smithy_legacy_http_server::response::Response,
          55  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          56  +
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          58  +
    Ok({
          59  +
        /* RustType.kt:534 */
          60  +
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          62  +
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          64  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          65  +
            builder,
          66  +
            ::http::header::CONTENT_TYPE,
          67  +
            "application/json",
          68  +
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          70  +
        let http_status: u16 = 200;
          71  +
        builder = builder.status(http_status);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          73  +
        let payload =
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          77  +
        let content_length = payload.len();
          78  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          79  +
            builder,
          80  +
            ::http::header::CONTENT_LENGTH,
          81  +
            content_length,
          82  +
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          84  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          86  +
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          88  +
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          90  +
}
          91  +
          92  +
/* JsonParserGenerator.kt:148 */
          93  +
pub(crate) fn de_malformed_content_type_with_body(
          94  +
    value: &[u8],
          95  +
    mut builder: crate::input::malformed_content_type_with_body_input::Builder,
          96  +
) -> ::std::result::Result<
          97  +
    crate::input::malformed_content_type_with_body_input::Builder,
          98  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          99  +
> {
         100  +
    /* JsonParserGenerator.kt:153 */
         101  +
    let mut tokens_owned =
         102  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         103  +
            .peekable();
         104  +
    let tokens = &mut tokens_owned;
         105  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         106  +
    /* JsonParserGenerator.kt:684 */
         107  +
    loop {
         108  +
        /* JsonParserGenerator.kt:685 */
         109  +
        match tokens.next().transpose()? {
         110  +
            /* JsonParserGenerator.kt:686 */
         111  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         112  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         113  +
                /* JsonParserGenerator.kt:260 */
         114  +
                match key.to_unescaped()?.as_ref() {
         115  +
                    /* JsonParserGenerator.kt:262 */
         116  +
                    "hi" => {
         117  +
                        /* JsonParserGenerator.kt:272 */
         118  +
                        builder = builder.set_hi(
         119  +
                            /* JsonParserGenerator.kt:354 */
         120  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         121  +
                                tokens.next(),
         122  +
                            )?
         123  +
                            .map(|s|
         124  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         125  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         126  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         127  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         128  +
                        );
         129  +
                        /* JsonParserGenerator.kt:262 */
         130  +
                    }
         131  +
                    /* JsonParserGenerator.kt:290 */
         132  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         133  +
                }
         134  +
                /* JsonParserGenerator.kt:686 */
         135  +
            }
         136  +
            /* JsonParserGenerator.kt:695 */
         137  +
            other => {
         138  +
                return Err(
         139  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         140  +
                        "expected object key or end object, found: {other:?}"
         141  +
                    )),
         142  +
                )
         143  +
            } /* JsonParserGenerator.kt:685 */
         144  +
        }
         145  +
        /* JsonParserGenerator.kt:684 */
         146  +
    }
         147  +
    /* JsonParserGenerator.kt:250 */
         148  +
    if tokens.next().is_some() {
         149  +
        /* JsonParserGenerator.kt:251 */
         150  +
        return Err(
         151  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         152  +
                "found more JSON tokens after completing parsing",
         153  +
            ),
         154  +
        );
         155  +
        /* JsonParserGenerator.kt:250 */
         156  +
    }
         157  +
    /* JsonParserGenerator.kt:163 */
         158  +
    Ok(builder)
         159  +
    /* JsonParserGenerator.kt:148 */
         160  +
}

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

@@ -0,1 +0,92 @@
           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_generic_string_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedContentTypeWithGenericStringInput,
           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_with_generic_string_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) = {
          32  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          33  +
            if !bytes.is_empty() {
          34  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                    &headers,
          36  +
                    Some("text/plain"),
          37  +
                )?;
          38  +
            }
          39  +
            crate::protocol_serde::shape_malformed_content_type_with_generic_string_input::de_payload_payload(&bytes)?
          40  +
        } {
          41  +
            input = input.set_payload(Some(value))
          42  +
        }
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          44  +
        input.build()
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          46  +
    })
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          48  +
}
          49  +
          50  +
/* RustType.kt:534 */
          51  +
#[allow(clippy::unnecessary_wraps)]
          52  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          53  +
pub fn ser_malformed_content_type_with_generic_string_http_response(
          54  +
    #[allow(unused_variables)] output: crate::output::MalformedContentTypeWithGenericStringOutput,
          55  +
) -> std::result::Result<
          56  +
    ::aws_smithy_legacy_http_server::response::Response,
          57  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          58  +
> {
          59  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          60  +
    Ok({
          61  +
        /* RustType.kt:534 */
          62  +
        #[allow(unused_mut)]
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          64  +
        let mut builder = ::http::Response::builder();
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          66  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          67  +
            builder,
          68  +
            ::http::header::CONTENT_TYPE,
          69  +
            "application/json",
          70  +
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          72  +
        let http_status: u16 = 200;
          73  +
        builder = builder.status(http_status);
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          75  +
        let payload =
          76  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          79  +
        let content_length = payload.len();
          80  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          81  +
            builder,
          82  +
            ::http::header::CONTENT_LENGTH,
          83  +
            content_length,
          84  +
        );
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          86  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          88  +
        builder.body(body)?
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          90  +
    })
          91  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          92  +
}