Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9

Files changed:

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

@@ -0,1 +0,83 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_dialog_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, crate::model::Dialog>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_dialog::de_dialog(tokens)?
          40  +
                        /* JsonParserGenerator.kt:474 */;
          41  +
                        /* JsonParserGenerator.kt:481 */
          42  +
                        match value {
          43  +
                            Some(value) => {
          44  +
                                map.insert(key, value);
          45  +
                            }
          46  +
                            None => {
          47  +
                                return Err(
          48  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          49  +
                                        "dense map cannot contain null values",
          50  +
                                    ),
          51  +
                                )
          52  +
                            }
          53  +
                        }
          54  +
                        /* JsonParserGenerator.kt:686 */
          55  +
                    }
          56  +
                    /* JsonParserGenerator.kt:695 */
          57  +
                    other => {
          58  +
                        return Err(
          59  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          60  +
                                format!("expected object key or end object, found: {other:?}"),
          61  +
                            ),
          62  +
                        )
          63  +
                    } /* JsonParserGenerator.kt:685 */
          64  +
                }
          65  +
                /* JsonParserGenerator.kt:684 */
          66  +
            }
          67  +
            /* JsonParserGenerator.kt:504 */
          68  +
            Ok(Some(map))
          69  +
            /* JsonParserGenerator.kt:713 */
          70  +
        }
          71  +
        /* JsonParserGenerator.kt:722 */
          72  +
        _ => {
          73  +
            /* JsonParserGenerator.kt:723 */
          74  +
            Err(
          75  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          76  +
                    "expected start object or null",
          77  +
                ),
          78  +
            )
          79  +
            /* JsonParserGenerator.kt:722 */
          80  +
        } /* JsonParserGenerator.kt:712 */
          81  +
    }
          82  +
    /* JsonParserGenerator.kt:460 */
          83  +
}

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

@@ -0,1 +0,29 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:175 */
           3  +
pub(crate) fn de_document_payload(
           4  +
    input: &[u8],
           5  +
) -> ::std::result::Result<
           6  +
    ::aws_smithy_types::Document,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* JsonParserGenerator.kt:187 */
          10  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(input).peekable();
          11  +
    let tokens = &mut tokens_owned;
          12  +
    /* JsonParserGenerator.kt:194 */
          13  +
    let result =
          14  +
    /* JsonParserGenerator.kt:319 */Some(::aws_smithy_json::deserialize::token::expect_document(tokens)?)
          15  +
    /* JsonParserGenerator.kt:196 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          16  +
    /* JsonParserGenerator.kt:250 */
          17  +
    if tokens.next().is_some() {
          18  +
        /* JsonParserGenerator.kt:251 */
          19  +
        return Err(
          20  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          21  +
                "found more JSON tokens after completing parsing",
          22  +
            ),
          23  +
        );
          24  +
        /* JsonParserGenerator.kt:250 */
          25  +
    }
          26  +
    /* JsonParserGenerator.kt:198 */
          27  +
    result
          28  +
    /* JsonParserGenerator.kt:175 */
          29  +
}

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

@@ -0,1 +0,174 @@
           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_document_type_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DocumentTypeInput,
           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::document_type_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_document_type::de_document_type(
          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_document_type_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::DocumentTypeOutput,
          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:235 */crate::protocol_serde::shape_document_type_output::ser_document_type_output_output_output(&output)?
          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_document_type(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::document_type_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::document_type_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  +
                    "documentValue" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_document_value(
         122  +
                            /* JsonParserGenerator.kt:319 */
         123  +
                            Some(::aws_smithy_json::deserialize::token::expect_document(
         124  +
                                tokens,
         125  +
                            )?), /* JsonParserGenerator.kt:272 */
         126  +
                        );
         127  +
                        /* JsonParserGenerator.kt:262 */
         128  +
                    }
         129  +
                    /* JsonParserGenerator.kt:262 */
         130  +
                    "stringValue" => {
         131  +
                        /* JsonParserGenerator.kt:272 */
         132  +
                        builder = builder.set_string_value(
         133  +
                            /* JsonParserGenerator.kt:354 */
         134  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         135  +
                                tokens.next(),
         136  +
                            )?
         137  +
                            .map(|s|
         138  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         139  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         140  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         141  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         142  +
                        );
         143  +
                        /* JsonParserGenerator.kt:262 */
         144  +
                    }
         145  +
                    /* JsonParserGenerator.kt:290 */
         146  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         147  +
                }
         148  +
                /* JsonParserGenerator.kt:686 */
         149  +
            }
         150  +
            /* JsonParserGenerator.kt:695 */
         151  +
            other => {
         152  +
                return Err(
         153  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         154  +
                        "expected object key or end object, found: {other:?}"
         155  +
                    )),
         156  +
                )
         157  +
            } /* JsonParserGenerator.kt:685 */
         158  +
        }
         159  +
        /* JsonParserGenerator.kt:684 */
         160  +
    }
         161  +
    /* JsonParserGenerator.kt:250 */
         162  +
    if tokens.next().is_some() {
         163  +
        /* JsonParserGenerator.kt:251 */
         164  +
        return Err(
         165  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         166  +
                "found more JSON tokens after completing parsing",
         167  +
            ),
         168  +
        );
         169  +
        /* JsonParserGenerator.kt:250 */
         170  +
    }
         171  +
    /* JsonParserGenerator.kt:163 */
         172  +
    Ok(builder)
         173  +
    /* JsonParserGenerator.kt:148 */
         174  +
}

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

@@ -0,1 +0,152 @@
           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_document_type_as_map_value_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DocumentTypeAsMapValueInput,
           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::document_type_as_map_value_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_document_type_as_map_value::de_document_type_as_map_value(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_document_type_as_map_value_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::DocumentTypeAsMapValueOutput,
          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:235 */crate::protocol_serde::shape_document_type_as_map_value_output::ser_document_type_as_map_value_output_output_output(&output)?
          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_document_type_as_map_value(
          94  +
    value: &[u8],
          95  +
    mut builder: crate::input::document_type_as_map_value_input::Builder,
          96  +
) -> ::std::result::Result<
          97  +
    crate::input::document_type_as_map_value_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  +
                    "docValuedMap" => {
         117  +
                        /* JsonParserGenerator.kt:272 */
         118  +
                        builder = builder.set_doc_valued_map(
         119  +
                            /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_document_valued_map::de_document_valued_map(tokens)?
         120  +
                        /* JsonParserGenerator.kt:272 */);
         121  +
                        /* JsonParserGenerator.kt:262 */
         122  +
                    }
         123  +
                    /* JsonParserGenerator.kt:290 */
         124  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         125  +
                }
         126  +
                /* JsonParserGenerator.kt:686 */
         127  +
            }
         128  +
            /* JsonParserGenerator.kt:695 */
         129  +
            other => {
         130  +
                return Err(
         131  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         132  +
                        "expected object key or end object, found: {other:?}"
         133  +
                    )),
         134  +
                )
         135  +
            } /* JsonParserGenerator.kt:685 */
         136  +
        }
         137  +
        /* JsonParserGenerator.kt:684 */
         138  +
    }
         139  +
    /* JsonParserGenerator.kt:250 */
         140  +
    if tokens.next().is_some() {
         141  +
        /* JsonParserGenerator.kt:251 */
         142  +
        return Err(
         143  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         144  +
                "found more JSON tokens after completing parsing",
         145  +
            ),
         146  +
        );
         147  +
        /* JsonParserGenerator.kt:250 */
         148  +
    }
         149  +
    /* JsonParserGenerator.kt:163 */
         150  +
    Ok(builder)
         151  +
    /* JsonParserGenerator.kt:148 */
         152  +
}

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

@@ -0,1 +0,45 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_document_type_as_map_value_output_output_output(
           4  +
    value: &crate::output::DocumentTypeAsMapValueOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_document_type_as_map_value_output::ser_document_type_as_map_value_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_document_type_as_map_value_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::DocumentTypeAsMapValueOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
          23  +
    if let Some(var_1) = &input.doc_valued_map {
          24  +
        /* JsonSerializerGenerator.kt:495 */
          25  +
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
          27  +
        let mut object_2 = object.key("docValuedMap").start_object();
          28  +
        /* JsonSerializerGenerator.kt:537 */
          29  +
        for (key_3, value_4) in var_1 {
          30  +
            /* SerializerUtil.kt:42 */
          31  +
            {
          32  +
                /* JsonSerializerGenerator.kt:474 */
          33  +
                object_2.key(key_3.as_str()).document(value_4);
          34  +
                /* SerializerUtil.kt:42 */
          35  +
            }
          36  +
            /* JsonSerializerGenerator.kt:537 */
          37  +
        }
          38  +
        /* JsonSerializerGenerator.kt:515 */
          39  +
        object_2.finish();
          40  +
        /* JsonSerializerGenerator.kt:382 */
          41  +
    }
          42  +
    /* JsonSerializerGenerator.kt:372 */
          43  +
    Ok(())
          44  +
    /* JsonSerializerGenerator.kt:358 */
          45  +
}

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

@@ -0,1 +0,93 @@
           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_document_type_as_payload_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DocumentTypeAsPayloadInput,
           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::document_type_as_payload_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          30  +
        if let Some(value) = {
          31  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
            if !bytes.is_empty() {
          33  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          34  +
                    &headers,
          35  +
                    Some("application/json"),
          36  +
                )?;
          37  +
            }
          38  +
            crate::protocol_serde::shape_document_type_as_payload_input::de_document_value_payload(
          39  +
                &bytes,
          40  +
            )?
          41  +
        } {
          42  +
            input = input.set_document_value(Some(value))
          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_document_type_as_payload_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::DocumentTypeAsPayloadOutput,
          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:348 */crate::protocol_serde::shape_document_type_as_payload_output::ser_document_value_http_payload(& output.document_value)?
          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  +
}

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

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

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_document_type_as_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_document_value_http_payload(
           4  +
    payload: &::std::option::Option<::aws_smithy_types::Document>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload.as_ref() {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:330 */
          12  +
                Vec::new(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:391 */
          19  +
        crate::protocol_serde::serialize_document(payload), /* 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_document_type_output.rs

@@ -0,1 +0,40 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_document_type_output_output_output(
           4  +
    value: &crate::output::DocumentTypeOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_document_type_output::ser_document_type_output_output(
          11  +
        &mut object,
          12  +
        value,
          13  +
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
          15  +
    object.finish();
          16  +
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
          18  +
}
          19  +
          20  +
/* JsonSerializerGenerator.kt:358 */
          21  +
pub fn ser_document_type_output_output(
          22  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    input: &crate::output::DocumentTypeOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
          26  +
    if let Some(var_1) = &input.document_value {
          27  +
        /* JsonSerializerGenerator.kt:474 */
          28  +
        object.key("documentValue").document(var_1);
          29  +
        /* JsonSerializerGenerator.kt:382 */
          30  +
    }
          31  +
    /* JsonSerializerGenerator.kt:382 */
          32  +
    if let Some(var_2) = &input.string_value {
          33  +
        /* JsonSerializerGenerator.kt:423 */
          34  +
        object.key("stringValue").string(var_2.as_str());
          35  +
        /* JsonSerializerGenerator.kt:382 */
          36  +
    }
          37  +
    /* JsonSerializerGenerator.kt:372 */
          38  +
    Ok(())
          39  +
    /* JsonSerializerGenerator.kt:358 */
          40  +
}

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

@@ -0,1 +0,83 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_document_valued_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<::std::collections::HashMap<::std::string::String, ::aws_smithy_types::Document>>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
>
           9  +
where
          10  +
    I: Iterator<
          11  +
        Item = Result<
          12  +
            ::aws_smithy_json::deserialize::Token<'a>,
          13  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          14  +
        >,
          15  +
    >,
          16  +
{
          17  +
    /* JsonParserGenerator.kt:712 */
          18  +
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
          20  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          21  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:319 */Some(::aws_smithy_json::deserialize::token::expect_document(tokens)?)
          40  +
                        /* JsonParserGenerator.kt:474 */;
          41  +
                        /* JsonParserGenerator.kt:481 */
          42  +
                        match value {
          43  +
                            Some(value) => {
          44  +
                                map.insert(key, value);
          45  +
                            }
          46  +
                            None => {
          47  +
                                return Err(
          48  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          49  +
                                        "dense map cannot contain null values",
          50  +
                                    ),
          51  +
                                )
          52  +
                            }
          53  +
                        }
          54  +
                        /* JsonParserGenerator.kt:686 */
          55  +
                    }
          56  +
                    /* JsonParserGenerator.kt:695 */
          57  +
                    other => {
          58  +
                        return Err(
          59  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          60  +
                                format!("expected object key or end object, found: {other:?}"),
          61  +
                            ),
          62  +
                        )
          63  +
                    } /* JsonParserGenerator.kt:685 */
          64  +
                }
          65  +
                /* JsonParserGenerator.kt:684 */
          66  +
            }
          67  +
            /* JsonParserGenerator.kt:504 */
          68  +
            Ok(Some(map))
          69  +
            /* JsonParserGenerator.kt:713 */
          70  +
        }
          71  +
        /* JsonParserGenerator.kt:722 */
          72  +
        _ => {
          73  +
            /* JsonParserGenerator.kt:723 */
          74  +
            Err(
          75  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          76  +
                    "expected start object or null",
          77  +
                ),
          78  +
            )
          79  +
            /* JsonParserGenerator.kt:722 */
          80  +
        } /* JsonParserGenerator.kt:712 */
          81  +
    }
          82  +
    /* JsonParserGenerator.kt:460 */
          83  +
}

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

@@ -0,1 +0,78 @@
           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_empty_input_and_empty_output_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::EmptyInputAndEmptyOutputInput,
           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::empty_input_and_empty_output_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          30  +
        input.build()
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          32  +
    })
          33  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          34  +
}
          35  +
          36  +
/* RustType.kt:534 */
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          39  +
pub fn ser_empty_input_and_empty_output_http_response(
          40  +
    #[allow(unused_variables)] output: crate::output::EmptyInputAndEmptyOutputOutput,
          41  +
) -> std::result::Result<
          42  +
    ::aws_smithy_legacy_http_server::response::Response,
          43  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          44  +
> {
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          46  +
    Ok({
          47  +
        /* RustType.kt:534 */
          48  +
        #[allow(unused_mut)]
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          50  +
        let mut builder = ::http::Response::builder();
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          52  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          53  +
            builder,
          54  +
            ::http::header::CONTENT_TYPE,
          55  +
            "application/json",
          56  +
        );
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          58  +
        let http_status: u16 = 200;
          59  +
        builder = builder.status(http_status);
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          61  +
        let payload =
          62  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_empty_input_and_empty_output_output::ser_empty_input_and_empty_output_output_output_output(&output)?
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          65  +
        let content_length = payload.len();
          66  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          67  +
            builder,
          68  +
            ::http::header::CONTENT_LENGTH,
          69  +
            content_length,
          70  +
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          72  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          74  +
        builder.body(body)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          76  +
    })
          77  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          78  +
}

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

@@ -0,1 +0,25 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_empty_input_and_empty_output_output_output_output(
           4  +
    value: &crate::output::EmptyInputAndEmptyOutputOutput,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
          10  +
    crate::protocol_serde::shape_empty_input_and_empty_output_output::ser_empty_input_and_empty_output_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:358 */
          18  +
pub fn ser_empty_input_and_empty_output_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::EmptyInputAndEmptyOutputOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:372 */
          23  +
    Ok(())
          24  +
    /* JsonSerializerGenerator.kt:358 */
          25  +
}

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

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

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

@@ -0,1 +0,215 @@
           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_endpoint_with_host_label_operation_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::EndpointWithHostLabelOperationInput,
           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::endpoint_with_host_label_operation_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_endpoint_with_host_label_operation::de_endpoint_with_host_label_operation(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_endpoint_with_host_label_operation_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::EndpointWithHostLabelOperationOutput,
          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  +
/* RustType.kt:534 */
          93  +
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          95  +
pub fn ser_endpoint_with_host_label_operation_http_error(
          96  +
    error: &crate::error::EndpointWithHostLabelOperationError,
          97  +
) -> std::result::Result<
          98  +
    ::aws_smithy_legacy_http_server::response::Response,
          99  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         100  +
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         102  +
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         104  +
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         106  +
            crate::error::EndpointWithHostLabelOperationError::ValidationException(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         108  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         109  +
                /* RustType.kt:534 */
         110  +
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         112  +
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         114  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         115  +
                    builder,
         116  +
                    ::http::header::CONTENT_TYPE,
         117  +
                    "application/json",
         118  +
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         120  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         121  +
                    builder,
         122  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         123  +
                    "ValidationException",
         124  +
                );
         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:528 */
         133  +
                builder
         134  +
                    .status(400)
         135  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         138  +
        }
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         140  +
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         142  +
}
         143  +
         144  +
/* JsonParserGenerator.kt:148 */
         145  +
pub(crate) fn de_endpoint_with_host_label_operation(
         146  +
    value: &[u8],
         147  +
    mut builder: crate::input::endpoint_with_host_label_operation_input::Builder,
         148  +
) -> ::std::result::Result<
         149  +
    crate::input::endpoint_with_host_label_operation_input::Builder,
         150  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         151  +
> {
         152  +
    /* JsonParserGenerator.kt:153 */
         153  +
    let mut tokens_owned =
         154  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         155  +
            .peekable();
         156  +
    let tokens = &mut tokens_owned;
         157  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         158  +
    /* JsonParserGenerator.kt:684 */
         159  +
    loop {
         160  +
        /* JsonParserGenerator.kt:685 */
         161  +
        match tokens.next().transpose()? {
         162  +
            /* JsonParserGenerator.kt:686 */
         163  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         164  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         165  +
                /* JsonParserGenerator.kt:260 */
         166  +
                match key.to_unescaped()?.as_ref() {
         167  +
                    /* JsonParserGenerator.kt:262 */
         168  +
                    "label" => {
         169  +
                        /* JsonParserGenerator.kt:276 */
         170  +
                        if let Some(v) =
         171  +
                            /* JsonParserGenerator.kt:354 */
         172  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         173  +
                                    tokens.next(),
         174  +
                                )?
         175  +
                                .map(|s|
         176  +
                            /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         177  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
         178  +
                            /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         179  +
                                .transpose()?
         180  +
                        /* JsonParserGenerator.kt:278 */
         181  +
                        {
         182  +
                            builder = builder.set_label(v);
         183  +
                        }
         184  +
                        /* JsonParserGenerator.kt:262 */
         185  +
                    }
         186  +
                    /* JsonParserGenerator.kt:290 */
         187  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         188  +
                }
         189  +
                /* JsonParserGenerator.kt:686 */
         190  +
            }
         191  +
            /* JsonParserGenerator.kt:695 */
         192  +
            other => {
         193  +
                return Err(
         194  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         195  +
                        "expected object key or end object, found: {other:?}"
         196  +
                    )),
         197  +
                )
         198  +
            } /* JsonParserGenerator.kt:685 */
         199  +
        }
         200  +
        /* JsonParserGenerator.kt:684 */
         201  +
    }
         202  +
    /* JsonParserGenerator.kt:250 */
         203  +
    if tokens.next().is_some() {
         204  +
        /* JsonParserGenerator.kt:251 */
         205  +
        return Err(
         206  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         207  +
                "found more JSON tokens after completing parsing",
         208  +
            ),
         209  +
        );
         210  +
        /* JsonParserGenerator.kt:250 */
         211  +
    }
         212  +
    /* JsonParserGenerator.kt:163 */
         213  +
    Ok(builder)
         214  +
    /* JsonParserGenerator.kt:148 */
         215  +
}