Server Test

Server Test

rev. 3c756f73b1f83a0eed4275d9d1e22df0b10b66fb (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,155 @@
           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_list_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedListInput,
           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_list_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_list::de_malformed_list(
          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_list_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::MalformedListOutput,
          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_list(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::malformed_list_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::malformed_list_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  +
                    "bodyList" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_body_list(
         122  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_simple_list::de_simple_list(tokens)?
         123  +
                        /* JsonParserGenerator.kt:272 */);
         124  +
                        /* JsonParserGenerator.kt:262 */
         125  +
                    }
         126  +
                    /* JsonParserGenerator.kt:290 */
         127  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         128  +
                }
         129  +
                /* JsonParserGenerator.kt:686 */
         130  +
            }
         131  +
            /* JsonParserGenerator.kt:695 */
         132  +
            other => {
         133  +
                return Err(
         134  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         135  +
                        "expected object key or end object, found: {other:?}"
         136  +
                    )),
         137  +
                )
         138  +
            } /* JsonParserGenerator.kt:685 */
         139  +
        }
         140  +
        /* JsonParserGenerator.kt:684 */
         141  +
    }
         142  +
    /* JsonParserGenerator.kt:250 */
         143  +
    if tokens.next().is_some() {
         144  +
        /* JsonParserGenerator.kt:251 */
         145  +
        return Err(
         146  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         147  +
                "found more JSON tokens after completing parsing",
         148  +
            ),
         149  +
        );
         150  +
        /* JsonParserGenerator.kt:250 */
         151  +
    }
         152  +
    /* JsonParserGenerator.kt:163 */
         153  +
    Ok(builder)
         154  +
    /* JsonParserGenerator.kt:148 */
         155  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_long.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_long_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedLongInput,
           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_long_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_long::de_malformed_long(
          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_long_input::de_long_in_header_header(&headers)?
          47  +
        {
          48  +
            input = input.set_long_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>>("MalformedLong"),
          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_long_in_path(
          70  +
            crate::protocol_serde::shape_malformed_long_input::de_long_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 long_in_query_seen = false;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          78  +
        for (k, v) in pairs {
          79  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          80  +
            if !long_in_query_seen && k == "longInQuery" {
          81  +
                input = input.set_long_in_query(
          82  +
                    crate::protocol_serde::shape_malformed_long_input::de_long_in_query(&v)?,
          83  +
                );
          84  +
                long_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_long_http_response(
          99  +
    #[allow(unused_variables)] output: crate::output::MalformedLongOutput,
         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_long_http_error(
         143  +
    error: &crate::error::MalformedLongError,
         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::MalformedLongError::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_long(
         193  +
    value: &[u8],
         194  +
    mut builder: crate::input::malformed_long_input::Builder,
         195  +
) -> ::std::result::Result<
         196  +
    crate::input::malformed_long_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  +
                    "longInBody" => {
         216  +
                        /* JsonParserGenerator.kt:272 */
         217  +
                        builder = builder.set_long_in_body(
         218  +
                            /* JsonParserGenerator.kt:365 */
         219  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         220  +
                                tokens.next(),
         221  +
                            )?
         222  +
                            .map(i64::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_long_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_long_in_header_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<::std::option::Option<i64>, ::aws_smithy_legacy_http::header::ParseError>
           6  +
{
           7  +
    /* HttpBindingGenerator.kt:166 */
           8  +
    let headers = header_map.get_all("longInHeader");
           9  +
    /* HttpBindingGenerator.kt:427 */
          10  +
    let var_1 = ::aws_smithy_legacy_http::header::read_many_primitive::<i64>(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_long_in_path(
          26  +
    value: &str,
          27  +
) -> std::result::Result<
          28  +
    i64,
          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_long_in_query(
          40  +
    value: &str,
          41  +
) -> std::result::Result<
          42  +
    ::std::option::Option<i64>,
          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_map.rs

@@ -0,1 +0,155 @@
           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_map_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedMapInput,
           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_map_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_map::de_malformed_map(
          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_map_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::MalformedMapOutput,
          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_map(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::malformed_map_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::malformed_map_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  +
                    "bodyMap" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_body_map(
         122  +
                            /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_simple_map::de_simple_map(tokens)?
         123  +
                        /* JsonParserGenerator.kt:272 */);
         124  +
                        /* JsonParserGenerator.kt:262 */
         125  +
                    }
         126  +
                    /* JsonParserGenerator.kt:290 */
         127  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         128  +
                }
         129  +
                /* JsonParserGenerator.kt:686 */
         130  +
            }
         131  +
            /* JsonParserGenerator.kt:695 */
         132  +
            other => {
         133  +
                return Err(
         134  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         135  +
                        "expected object key or end object, found: {other:?}"
         136  +
                    )),
         137  +
                )
         138  +
            } /* JsonParserGenerator.kt:685 */
         139  +
        }
         140  +
        /* JsonParserGenerator.kt:684 */
         141  +
    }
         142  +
    /* JsonParserGenerator.kt:250 */
         143  +
    if tokens.next().is_some() {
         144  +
        /* JsonParserGenerator.kt:251 */
         145  +
        return Err(
         146  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         147  +
                "found more JSON tokens after completing parsing",
         148  +
            ),
         149  +
        );
         150  +
        /* JsonParserGenerator.kt:250 */
         151  +
    }
         152  +
    /* JsonParserGenerator.kt:163 */
         153  +
    Ok(builder)
         154  +
    /* JsonParserGenerator.kt:148 */
         155  +
}

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

@@ -0,1 +0,172 @@
           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_request_body_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedRequestBodyInput,
           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_request_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_request_body::de_malformed_request_body(
          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_request_body_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::MalformedRequestBodyOutput,
          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_request_body(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::malformed_request_body_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::malformed_request_body_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  +
                    "float" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_float(
         122  +
                            /* JsonParserGenerator.kt:361 */
         123  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         124  +
                                tokens.next(),
         125  +
                            )?
         126  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
         127  +
                        );
         128  +
                        /* JsonParserGenerator.kt:262 */
         129  +
                    }
         130  +
                    /* JsonParserGenerator.kt:262 */
         131  +
                    "int" => {
         132  +
                        /* JsonParserGenerator.kt:272 */
         133  +
                        builder = builder.set_int(
         134  +
                            /* JsonParserGenerator.kt:365 */
         135  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         136  +
                                tokens.next(),
         137  +
                            )?
         138  +
                            .map(i32::try_from)
         139  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         140  +
                        );
         141  +
                        /* JsonParserGenerator.kt:262 */
         142  +
                    }
         143  +
                    /* JsonParserGenerator.kt:290 */
         144  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         145  +
                }
         146  +
                /* JsonParserGenerator.kt:686 */
         147  +
            }
         148  +
            /* JsonParserGenerator.kt:695 */
         149  +
            other => {
         150  +
                return Err(
         151  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         152  +
                        "expected object key or end object, found: {other:?}"
         153  +
                    )),
         154  +
                )
         155  +
            } /* JsonParserGenerator.kt:685 */
         156  +
        }
         157  +
        /* JsonParserGenerator.kt:684 */
         158  +
    }
         159  +
    /* JsonParserGenerator.kt:250 */
         160  +
    if tokens.next().is_some() {
         161  +
        /* JsonParserGenerator.kt:251 */
         162  +
        return Err(
         163  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         164  +
                "found more JSON tokens after completing parsing",
         165  +
            ),
         166  +
        );
         167  +
        /* JsonParserGenerator.kt:250 */
         168  +
    }
         169  +
    /* JsonParserGenerator.kt:163 */
         170  +
    Ok(builder)
         171  +
    /* JsonParserGenerator.kt:148 */
         172  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_short.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_short_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedShortInput,
           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_short_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_short::de_malformed_short(
          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_short_input::de_short_in_header_header(&headers)?
          47  +
        {
          48  +
            input = input.set_short_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  +
                        "MalformedShort",
          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_short_in_path(
          72  +
            crate::protocol_serde::shape_malformed_short_input::de_short_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 short_in_query_seen = false;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          80  +
        for (k, v) in pairs {
          81  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          82  +
            if !short_in_query_seen && k == "shortInQuery" {
          83  +
                input = input.set_short_in_query(
          84  +
                    crate::protocol_serde::shape_malformed_short_input::de_short_in_query(&v)?,
          85  +
                );
          86  +
                short_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_short_http_response(
         101  +
    #[allow(unused_variables)] output: crate::output::MalformedShortOutput,
         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_short_http_error(
         145  +
    error: &crate::error::MalformedShortError,
         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::MalformedShortError::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_short(
         195  +
    value: &[u8],
         196  +
    mut builder: crate::input::malformed_short_input::Builder,
         197  +
) -> ::std::result::Result<
         198  +
    crate::input::malformed_short_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  +
                    "shortInBody" => {
         218  +
                        /* JsonParserGenerator.kt:272 */
         219  +
                        builder = builder.set_short_in_body(
         220  +
                            /* JsonParserGenerator.kt:365 */
         221  +
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
         222  +
                                tokens.next(),
         223  +
                            )?
         224  +
                            .map(i16::try_from)
         225  +
                            .transpose()?, /* 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  +
}