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_timestamp_query_epoch_input.rs

@@ -0,1 +0,15 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
           3  +
pub fn de_timestamp(
           4  +
    value: &str,
           5  +
) -> std::result::Result<
           6  +
    ::aws_smithy_types::DateTime,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1495 */
          10  +
    let value = ::aws_smithy_types::DateTime::from_str(value, ::aws_smithy_types::date_time::Format::EpochSeconds)?
          11  +
    /* ServerHttpBoundProtocolGenerator.kt:1510 */;
          12  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          13  +
    Ok(value)
          14  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          15  +
}

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

@@ -0,1 +0,146 @@
           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_timestamp_query_http_date_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedTimestampQueryHttpDateInput,
           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_timestamp_query_http_date_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:1221 */
          30  +
        let query_string = uri.query().unwrap_or("");
          31  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
          33  +
        let mut timestamp_seen = false;
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          35  +
        for (k, v) in pairs {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          37  +
            if !timestamp_seen && k == "timestamp" {
          38  +
                input = input.set_timestamp(
          39  +
                    crate::protocol_serde::shape_malformed_timestamp_query_http_date_input::de_timestamp(&v)?
          40  +
                );
          41  +
                timestamp_seen = true;
          42  +
            }
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
          44  +
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          46  +
        input.build()?
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          48  +
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          50  +
}
          51  +
          52  +
/* RustType.kt:534 */
          53  +
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          55  +
pub fn ser_malformed_timestamp_query_http_date_http_response(
          56  +
    #[allow(unused_variables)] output: crate::output::MalformedTimestampQueryHttpDateOutput,
          57  +
) -> std::result::Result<
          58  +
    ::aws_smithy_legacy_http_server::response::Response,
          59  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          60  +
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          62  +
    Ok({
          63  +
        /* RustType.kt:534 */
          64  +
        #[allow(unused_mut)]
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          66  +
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          68  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          69  +
            builder,
          70  +
            ::http::header::CONTENT_TYPE,
          71  +
            "application/json",
          72  +
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          74  +
        let http_status: u16 = 200;
          75  +
        builder = builder.status(http_status);
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          77  +
        let payload =
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          81  +
        let content_length = payload.len();
          82  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          83  +
            builder,
          84  +
            ::http::header::CONTENT_LENGTH,
          85  +
            content_length,
          86  +
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          88  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          90  +
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          92  +
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          94  +
}
          95  +
          96  +
/* RustType.kt:534 */
          97  +
#[allow(clippy::unnecessary_wraps)]
          98  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          99  +
pub fn ser_malformed_timestamp_query_http_date_http_error(
         100  +
    error: &crate::error::MalformedTimestampQueryHttpDateError,
         101  +
) -> std::result::Result<
         102  +
    ::aws_smithy_legacy_http_server::response::Response,
         103  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         104  +
> {
         105  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         106  +
    Ok({
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         108  +
        match error {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         110  +
            crate::error::MalformedTimestampQueryHttpDateError::ValidationException(output) => {
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         112  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         113  +
                /* RustType.kt:534 */
         114  +
                #[allow(unused_mut)]
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         116  +
                let mut builder = ::http::Response::builder();
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         118  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         119  +
                    builder,
         120  +
                    ::http::header::CONTENT_TYPE,
         121  +
                    "application/json",
         122  +
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         124  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         125  +
                    builder,
         126  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         127  +
                    "ValidationException",
         128  +
                );
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         130  +
                let content_length = payload.len();
         131  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         132  +
                    builder,
         133  +
                    ::http::header::CONTENT_LENGTH,
         134  +
                    content_length,
         135  +
                );
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         137  +
                builder
         138  +
                    .status(400)
         139  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         141  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         142  +
        }
         143  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         144  +
    })
         145  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         146  +
}

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

@@ -0,1 +0,15 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
           3  +
pub fn de_timestamp(
           4  +
    value: &str,
           5  +
) -> std::result::Result<
           6  +
    ::aws_smithy_types::DateTime,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1495 */
          10  +
    let value = ::aws_smithy_types::DateTime::from_str(value, ::aws_smithy_types::date_time::Format::HttpDate)?
          11  +
    /* ServerHttpBoundProtocolGenerator.kt:1510 */;
          12  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          13  +
    Ok(value)
          14  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          15  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_malformed_union.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_union_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedUnionInput,
           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_union_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_union::de_malformed_union(
          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_union_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::MalformedUnionOutput,
          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_union(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::malformed_union_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::malformed_union_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  +
                    "union" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_union(
         122  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_simple_union::de_simple_union(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_media_type_header.rs

@@ -0,1 +0,121 @@
           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_media_type_header_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MediaTypeHeaderInput,
           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::media_type_header_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  +
            crate::protocol_serde::shape_media_type_header_input::de_json_header(&headers)?
          32  +
        {
          33  +
            input = input.set_json(Some(value))
          34  +
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          36  +
        input.build()
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          38  +
    })
          39  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          40  +
}
          41  +
          42  +
/* RustType.kt:534 */
          43  +
#[allow(clippy::unnecessary_wraps)]
          44  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          45  +
pub fn ser_media_type_header_http_response(
          46  +
    #[allow(unused_variables)] output: crate::output::MediaTypeHeaderOutput,
          47  +
) -> std::result::Result<
          48  +
    ::aws_smithy_legacy_http_server::response::Response,
          49  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          50  +
> {
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          52  +
    Ok({
          53  +
        /* RustType.kt:534 */
          54  +
        #[allow(unused_mut)]
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          56  +
        let mut builder = ::http::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          58  +
        builder = crate::protocol_serde::shape_media_type_header::ser_media_type_header_headers(
          59  +
            &output, builder,
          60  +
        )?;
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          62  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          63  +
            builder,
          64  +
            ::http::header::CONTENT_TYPE,
          65  +
            "application/json",
          66  +
        );
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          68  +
        let http_status: u16 = 200;
          69  +
        builder = builder.status(http_status);
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          71  +
        let payload =
          72  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_media_type_header_output::ser_media_type_header_output_output_output(&output)?
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          75  +
        let content_length = payload.len();
          76  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          77  +
            builder,
          78  +
            ::http::header::CONTENT_LENGTH,
          79  +
            content_length,
          80  +
        );
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          82  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          84  +
        builder.body(body)?
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          86  +
    })
          87  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          88  +
}
          89  +
          90  +
/* HttpBindingGenerator.kt:565 */
          91  +
pub fn ser_media_type_header_headers(
          92  +
    input: &crate::output::MediaTypeHeaderOutput,
          93  +
    mut builder: ::http::response::Builder,
          94  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          95  +
{
          96  +
    /* HttpBindingGenerator.kt:615 */
          97  +
    if let ::std::option::Option::Some(inner_1) = &input.json {
          98  +
        /* HttpBindingGenerator.kt:727 */
          99  +
        let formatted_2 = ::aws_smithy_types::base64::encode(inner_1);
         100  +
        /* HttpBindingGenerator.kt:728 */
         101  +
        if !formatted_2.is_empty() {
         102  +
            /* HttpBindingGenerator.kt:729 */
         103  +
            let header_value = formatted_2;
         104  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         105  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         106  +
                    "json",
         107  +
                    format!(
         108  +
                        "`{}` cannot be used as a header value: {}",
         109  +
                        &header_value, err
         110  +
                    ),
         111  +
                )
         112  +
            })?;
         113  +
            builder = builder.header("X-Json", header_value);
         114  +
            /* HttpBindingGenerator.kt:728 */
         115  +
        }
         116  +
        /* HttpBindingGenerator.kt:615 */
         117  +
    }
         118  +
    /* HttpBindingGenerator.kt:578 */
         119  +
    Ok(builder)
         120  +
    /* HttpBindingGenerator.kt:565 */
         121  +
}

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

@@ -0,1 +0,44 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_json_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> ::std::result::Result<
           6  +
    ::std::option::Option<::std::string::String>,
           7  +
    ::aws_smithy_legacy_http::header::ParseError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
          10  +
    let headers = header_map.get_all("X-Json");
          11  +
    /* HttpBindingGenerator.kt:432 */
          12  +
    let var_1: Vec<::std::string::String> =
          13  +
        ::aws_smithy_legacy_http::header::read_many_from_str(headers)?;
          14  +
    /* HttpBindingGenerator.kt:437 */
          15  +
    let var_1: std::result::Result<Vec<_>, _> = var_1
          16  +
        .iter()
          17  +
        .map(|s| {
          18  +
            ::aws_smithy_types::base64::decode(s)
          19  +
                .map_err(|_| {
          20  +
                    ::aws_smithy_legacy_http::header::ParseError::new("failed to decode base64")
          21  +
                })
          22  +
                .and_then(|bytes| {
          23  +
                    String::from_utf8(bytes).map_err(|_| {
          24  +
                        ::aws_smithy_legacy_http::header::ParseError::new(
          25  +
                            "base64 encoded data was not valid utf-8",
          26  +
                        )
          27  +
                    })
          28  +
                })
          29  +
        })
          30  +
        .collect();
          31  +
    /* HttpBindingGenerator.kt:448 */
          32  +
    let var_1 = var_1?;
          33  +
    /* HttpBindingGenerator.kt:491 */
          34  +
    if var_1.len() > 1 {
          35  +
        Err(::aws_smithy_legacy_http::header::ParseError::new(format!(
          36  +
            "expected one item but found {}",
          37  +
            var_1.len()
          38  +
        )))
          39  +
    } else {
          40  +
        let mut var_1 = var_1;
          41  +
        Ok(var_1.pop())
          42  +
    }
          43  +
    /* HttpBindingGenerator.kt:159 */
          44  +
}

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

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_media_type_header_output_output_output(
           4  +
    value: &crate::output::MediaTypeHeaderOutput,
           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_media_type_header_output::ser_media_type_header_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_media_type_header_output_output(
          22  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    #[allow(unused_variables)] input: &crate::output::MediaTypeHeaderOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:372 */
          26  +
    Ok(())
          27  +
    /* JsonSerializerGenerator.kt:358 */
          28  +
}

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

@@ -0,1 +0,363 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:551 */
           3  +
pub(crate) fn de_my_union<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained>,
           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:565 */
          18  +
    let mut variant = None;
          19  +
    /* JsonParserGenerator.kt:567 */
          20  +
    match tokens.next().transpose()? {
          21  +
        /* JsonParserGenerator.kt:568 */
          22  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          23  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          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:576 */
          32  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          33  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          34  +
                        )) = tokens.peek()
          35  +
                        {
          36  +
                            let _ = tokens.next().expect("peek returned a token")?;
          37  +
                            continue;
          38  +
                        }
          39  +
                        /* JsonParserGenerator.kt:585 */
          40  +
                        let key = key.to_unescaped()?;
          41  +
                        if key == "__type" {
          42  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          43  +
                            continue;
          44  +
                        }
          45  +
                        if variant.is_some() {
          46  +
                            return Err(
          47  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          48  +
                                    "encountered mixed variants in union",
          49  +
                                ),
          50  +
                            );
          51  +
                        }
          52  +
                        /* JsonParserGenerator.kt:598 */
          53  +
                        variant = match key.as_ref() {
          54  +
                            /* JsonParserGenerator.kt:601 */
          55  +
                            "stringValue" => {
          56  +
                                /* JsonParserGenerator.kt:611 */
          57  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StringValue(
          58  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          59  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          60  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          61  +
                                        /* JsonParserGenerator.kt:339 */)
          62  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          63  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'stringValue' cannot be null"))?
          64  +
                                /* JsonParserGenerator.kt:611 */))
          65  +
                                /* JsonParserGenerator.kt:601 */
          66  +
                            }
          67  +
                            /* JsonParserGenerator.kt:601 */
          68  +
                            "booleanValue" => {
          69  +
                                /* JsonParserGenerator.kt:611 */
          70  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BooleanValue(
          71  +
                                    /* JsonParserGenerator.kt:298 */::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?
          72  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'booleanValue' cannot be null"))?
          73  +
                                /* JsonParserGenerator.kt:611 */))
          74  +
                                /* JsonParserGenerator.kt:601 */
          75  +
                            }
          76  +
                            /* JsonParserGenerator.kt:601 */
          77  +
                            "numberValue" => {
          78  +
                                /* JsonParserGenerator.kt:611 */
          79  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::NumberValue(
          80  +
                                    /* JsonParserGenerator.kt:365 */::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
          81  +
                                                        .map(i32::try_from)
          82  +
                                                        .transpose()?
          83  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'numberValue' cannot be null"))?
          84  +
                                /* JsonParserGenerator.kt:611 */))
          85  +
                                /* JsonParserGenerator.kt:601 */
          86  +
                            }
          87  +
                            /* JsonParserGenerator.kt:601 */
          88  +
                            "blobValue" => {
          89  +
                                /* JsonParserGenerator.kt:611 */
          90  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::BlobValue(
          91  +
                                    /* JsonParserGenerator.kt:326 */::aws_smithy_json::deserialize::token::expect_blob_or_null(tokens.next())?
          92  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'blobValue' cannot be null"))?
          93  +
                                /* JsonParserGenerator.kt:611 */))
          94  +
                                /* JsonParserGenerator.kt:601 */
          95  +
                            }
          96  +
                            /* JsonParserGenerator.kt:601 */
          97  +
                            "timestampValue" => {
          98  +
                                /* JsonParserGenerator.kt:611 */
          99  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::TimestampValue(
         100  +
                                    /* JsonParserGenerator.kt:384 */::aws_smithy_json::deserialize::token::expect_timestamp_or_null(tokens.next(), ::aws_smithy_types::date_time::Format::EpochSeconds)?
         101  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'timestampValue' cannot be null"))?
         102  +
                                /* JsonParserGenerator.kt:611 */))
         103  +
                                /* JsonParserGenerator.kt:601 */
         104  +
                            }
         105  +
                            /* JsonParserGenerator.kt:601 */
         106  +
                            "enumValue" => {
         107  +
                                /* JsonParserGenerator.kt:611 */
         108  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::EnumValue(
         109  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
         110  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         111  +
                                            /* JsonParserGenerator.kt:343 */u.into_owned()
         112  +
                                        /* JsonParserGenerator.kt:339 */)
         113  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
         114  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'enumValue' cannot be null"))?
         115  +
                                /* JsonParserGenerator.kt:611 */))
         116  +
                                /* JsonParserGenerator.kt:601 */
         117  +
                            }
         118  +
                            /* JsonParserGenerator.kt:601 */
         119  +
                            "listValue" => {
         120  +
                                /* JsonParserGenerator.kt:611 */
         121  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::ListValue(
         122  +
                                    /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_list::de_string_list(tokens)?
         123  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'listValue' cannot be null"))?
         124  +
                                /* JsonParserGenerator.kt:611 */))
         125  +
                                /* JsonParserGenerator.kt:601 */
         126  +
                            }
         127  +
                            /* JsonParserGenerator.kt:601 */
         128  +
                            "mapValue" => {
         129  +
                                /* JsonParserGenerator.kt:611 */
         130  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::MapValue(
         131  +
                                    /* JsonParserGenerator.kt:509 */crate::protocol_serde::shape_string_map::de_string_map(tokens)?
         132  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'mapValue' cannot be null"))?
         133  +
                                /* JsonParserGenerator.kt:611 */))
         134  +
                                /* JsonParserGenerator.kt:601 */
         135  +
                            }
         136  +
                            /* JsonParserGenerator.kt:601 */
         137  +
                            "structureValue" => {
         138  +
                                /* JsonParserGenerator.kt:611 */
         139  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::StructureValue(
         140  +
                                    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_greeting_struct::de_greeting_struct(tokens)?
         141  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'structureValue' cannot be null"))?
         142  +
                                /* JsonParserGenerator.kt:611 */))
         143  +
                                /* JsonParserGenerator.kt:601 */
         144  +
                            }
         145  +
                            /* JsonParserGenerator.kt:601 */
         146  +
                            "renamedStructureValue" => {
         147  +
                                /* JsonParserGenerator.kt:611 */
         148  +
                                Some(crate::unconstrained::my_union_unconstrained::MyUnionUnconstrained::RenamedStructureValue(
         149  +
                                    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_renamed_greeting::de_renamed_greeting(tokens)?
         150  +
                                    /* JsonParserGenerator.kt:670 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'renamedStructureValue' cannot be null"))?
         151  +
                                /* JsonParserGenerator.kt:611 */))
         152  +
                                /* JsonParserGenerator.kt:601 */
         153  +
                            }
         154  +
                            /* JsonParserGenerator.kt:634 */
         155  +
                            variant => {
         156  +
                                return Err(
         157  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         158  +
                                        format!("unexpected union variant: {variant}"),
         159  +
                                    ),
         160  +
                                )
         161  +
                            } /* JsonParserGenerator.kt:598 */
         162  +
                        };
         163  +
                        /* JsonParserGenerator.kt:686 */
         164  +
                    }
         165  +
                    /* JsonParserGenerator.kt:695 */
         166  +
                    other => {
         167  +
                        return Err(
         168  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         169  +
                                format!("expected object key or end object, found: {other:?}"),
         170  +
                            ),
         171  +
                        )
         172  +
                    } /* JsonParserGenerator.kt:685 */
         173  +
                }
         174  +
                /* JsonParserGenerator.kt:684 */
         175  +
            }
         176  +
            /* JsonParserGenerator.kt:568 */
         177  +
        }
         178  +
        /* JsonParserGenerator.kt:642 */
         179  +
        _ => {
         180  +
            return Err(
         181  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         182  +
                    "expected start object or null",
         183  +
                ),
         184  +
            )
         185  +
        } /* JsonParserGenerator.kt:567 */
         186  +
    }
         187  +
    /* JsonParserGenerator.kt:649 */
         188  +
    if variant.is_none() {
         189  +
        return Err(
         190  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         191  +
                "Union did not contain a valid variant.",
         192  +
            ),
         193  +
        );
         194  +
    }
         195  +
    /* JsonParserGenerator.kt:657 */
         196  +
    Ok(variant)
         197  +
    /* JsonParserGenerator.kt:551 */
         198  +
}
         199  +
         200  +
/* JsonSerializerGenerator.kt:547 */
         201  +
pub fn ser_my_union(
         202  +
    object_2: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
         203  +
    input: &crate::model::MyUnion,
         204  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
         205  +
    /* JsonSerializerGenerator.kt:556 */
         206  +
    match input {
         207  +
        /* JsonSerializerGenerator.kt:564 */
         208  +
        crate::model::MyUnion::StringValue(inner) => {
         209  +
            /* SerializerUtil.kt:42 */
         210  +
            {
         211  +
                /* JsonSerializerGenerator.kt:423 */
         212  +
                object_2.key("stringValue").string(inner.as_str());
         213  +
                /* SerializerUtil.kt:42 */
         214  +
            }
         215  +
            /* JsonSerializerGenerator.kt:564 */
         216  +
        }
         217  +
        /* JsonSerializerGenerator.kt:564 */
         218  +
        crate::model::MyUnion::BooleanValue(inner) => {
         219  +
            /* SerializerUtil.kt:42 */
         220  +
            {
         221  +
                /* JsonSerializerGenerator.kt:424 */
         222  +
                object_2.key("booleanValue").boolean(*inner);
         223  +
                /* SerializerUtil.kt:42 */
         224  +
            }
         225  +
            /* JsonSerializerGenerator.kt:564 */
         226  +
        }
         227  +
        /* JsonSerializerGenerator.kt:564 */
         228  +
        crate::model::MyUnion::NumberValue(inner) => {
         229  +
            /* SerializerUtil.kt:42 */
         230  +
            {
         231  +
                /* JsonSerializerGenerator.kt:432 */
         232  +
                object_2.key("numberValue").number(
         233  +
                    #[allow(clippy::useless_conversion)]
         234  +
                    ::aws_smithy_types::Number::NegInt((*inner).into()),
         235  +
                );
         236  +
                /* SerializerUtil.kt:42 */
         237  +
            }
         238  +
            /* JsonSerializerGenerator.kt:564 */
         239  +
        }
         240  +
        /* JsonSerializerGenerator.kt:564 */
         241  +
        crate::model::MyUnion::BlobValue(inner) => {
         242  +
            /* SerializerUtil.kt:42 */
         243  +
            {
         244  +
                /* JsonSerializerGenerator.kt:439 */
         245  +
                object_2
         246  +
                    .key("blobValue")
         247  +
                    .string_unchecked(&::aws_smithy_types::base64::encode(inner));
         248  +
                /* SerializerUtil.kt:42 */
         249  +
            }
         250  +
            /* JsonSerializerGenerator.kt:564 */
         251  +
        }
         252  +
        /* JsonSerializerGenerator.kt:564 */
         253  +
        crate::model::MyUnion::TimestampValue(inner) => {
         254  +
            /* SerializerUtil.kt:42 */
         255  +
            {
         256  +
                /* JsonSerializerGenerator.kt:448 */
         257  +
                object_2
         258  +
                    .key("timestampValue")
         259  +
                    .date_time(inner, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
         260  +
                /* SerializerUtil.kt:42 */
         261  +
            }
         262  +
            /* JsonSerializerGenerator.kt:564 */
         263  +
        }
         264  +
        /* JsonSerializerGenerator.kt:564 */
         265  +
        crate::model::MyUnion::EnumValue(inner) => {
         266  +
            /* SerializerUtil.kt:42 */
         267  +
            {
         268  +
                /* JsonSerializerGenerator.kt:423 */
         269  +
                object_2.key("enumValue").string(inner.as_str());
         270  +
                /* SerializerUtil.kt:42 */
         271  +
            }
         272  +
            /* JsonSerializerGenerator.kt:564 */
         273  +
        }
         274  +
        /* JsonSerializerGenerator.kt:564 */
         275  +
        crate::model::MyUnion::ListValue(inner) => {
         276  +
            /* SerializerUtil.kt:42 */
         277  +
            {
         278  +
                /* JsonSerializerGenerator.kt:484 */
         279  +
                let mut array_1 = object_2.key("listValue").start_array();
         280  +
                /* JsonSerializerGenerator.kt:524 */
         281  +
                for item_2 in inner {
         282  +
                    /* SerializerUtil.kt:42 */
         283  +
                    {
         284  +
                        /* JsonSerializerGenerator.kt:423 */
         285  +
                        array_1.value().string(item_2.as_str());
         286  +
                        /* SerializerUtil.kt:42 */
         287  +
                    }
         288  +
                    /* JsonSerializerGenerator.kt:524 */
         289  +
                }
         290  +
                /* JsonSerializerGenerator.kt:486 */
         291  +
                array_1.finish();
         292  +
                /* SerializerUtil.kt:42 */
         293  +
            }
         294  +
            /* JsonSerializerGenerator.kt:564 */
         295  +
        }
         296  +
        /* JsonSerializerGenerator.kt:564 */
         297  +
        crate::model::MyUnion::MapValue(inner) => {
         298  +
            /* SerializerUtil.kt:42 */
         299  +
            {
         300  +
                /* JsonSerializerGenerator.kt:495 */
         301  +
                #[allow(unused_mut)]
         302  +
                /* JsonSerializerGenerator.kt:496 */
         303  +
                let mut object_3 = object_2.key("mapValue").start_object();
         304  +
                /* JsonSerializerGenerator.kt:537 */
         305  +
                for (key_4, value_5) in inner {
         306  +
                    /* SerializerUtil.kt:42 */
         307  +
                    {
         308  +
                        /* JsonSerializerGenerator.kt:423 */
         309  +
                        object_3.key(key_4.as_str()).string(value_5.as_str());
         310  +
                        /* SerializerUtil.kt:42 */
         311  +
                    }
         312  +
                    /* JsonSerializerGenerator.kt:537 */
         313  +
                }
         314  +
                /* JsonSerializerGenerator.kt:515 */
         315  +
                object_3.finish();
         316  +
                /* SerializerUtil.kt:42 */
         317  +
            }
         318  +
            /* JsonSerializerGenerator.kt:564 */
         319  +
        }
         320  +
        /* JsonSerializerGenerator.kt:564 */
         321  +
        crate::model::MyUnion::StructureValue(inner) => {
         322  +
            /* SerializerUtil.kt:42 */
         323  +
            {
         324  +
                /* JsonSerializerGenerator.kt:495 */
         325  +
                #[allow(unused_mut)]
         326  +
                /* JsonSerializerGenerator.kt:496 */
         327  +
                let mut object_6 = object_2.key("structureValue").start_object();
         328  +
                /* JsonSerializerGenerator.kt:375 */
         329  +
                crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
         330  +
                    &mut object_6,
         331  +
                    inner,
         332  +
                )?;
         333  +
                /* JsonSerializerGenerator.kt:515 */
         334  +
                object_6.finish();
         335  +
                /* SerializerUtil.kt:42 */
         336  +
            }
         337  +
            /* JsonSerializerGenerator.kt:564 */
         338  +
        }
         339  +
        /* JsonSerializerGenerator.kt:564 */
         340  +
        crate::model::MyUnion::RenamedStructureValue(inner) => {
         341  +
            /* SerializerUtil.kt:42 */
         342  +
            {
         343  +
                /* JsonSerializerGenerator.kt:495 */
         344  +
                #[allow(unused_mut)]
         345  +
                /* JsonSerializerGenerator.kt:496 */
         346  +
                let mut object_7 = object_2.key("renamedStructureValue").start_object();
         347  +
                /* JsonSerializerGenerator.kt:375 */
         348  +
                crate::protocol_serde::shape_renamed_greeting::ser_renamed_greeting(
         349  +
                    &mut object_7,
         350  +
                    inner,
         351  +
                )?;
         352  +
                /* JsonSerializerGenerator.kt:515 */
         353  +
                object_7.finish();
         354  +
                /* SerializerUtil.kt:42 */
         355  +
            }
         356  +
            /* JsonSerializerGenerator.kt:564 */
         357  +
        }
         358  +
        /* JsonSerializerGenerator.kt:556 */
         359  +
    }
         360  +
    /* JsonSerializerGenerator.kt:576 */
         361  +
    Ok(())
         362  +
    /* JsonSerializerGenerator.kt:547 */
         363  +
}

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

@@ -0,1 +0,144 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:175 */
           3  +
pub(crate) fn de_nested_payload_payload(
           4  +
    input: &[u8],
           5  +
) -> ::std::result::Result<
           6  +
    crate::model::NestedPayload,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* JsonParserGenerator.kt:187 */
          10  +
    let mut tokens_owned =
          11  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(input))
          12  +
            .peekable();
          13  +
    let tokens = &mut tokens_owned;
          14  +
    /* JsonParserGenerator.kt:194 */
          15  +
    let result =
          16  +
    /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_nested_payload::de_nested_payload(tokens)?
          17  +
    /* JsonParserGenerator.kt:196 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          18  +
    /* JsonParserGenerator.kt:250 */
          19  +
    if tokens.next().is_some() {
          20  +
        /* JsonParserGenerator.kt:251 */
          21  +
        return Err(
          22  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          23  +
                "found more JSON tokens after completing parsing",
          24  +
            ),
          25  +
        );
          26  +
        /* JsonParserGenerator.kt:250 */
          27  +
    }
          28  +
    /* JsonParserGenerator.kt:198 */
          29  +
    result
          30  +
    /* JsonParserGenerator.kt:175 */
          31  +
}
          32  +
          33  +
/* JsonSerializerGenerator.kt:358 */
          34  +
pub fn ser_nested_payload(
          35  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          36  +
    input: &crate::model::NestedPayload,
          37  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          38  +
    /* JsonSerializerGenerator.kt:382 */
          39  +
    if let Some(var_1) = &input.greeting {
          40  +
        /* JsonSerializerGenerator.kt:423 */
          41  +
        object.key("greeting").string(var_1.as_str());
          42  +
        /* JsonSerializerGenerator.kt:382 */
          43  +
    }
          44  +
    /* JsonSerializerGenerator.kt:382 */
          45  +
    if let Some(var_2) = &input.name {
          46  +
        /* JsonSerializerGenerator.kt:423 */
          47  +
        object.key("name").string(var_2.as_str());
          48  +
        /* JsonSerializerGenerator.kt:382 */
          49  +
    }
          50  +
    /* JsonSerializerGenerator.kt:372 */
          51  +
    Ok(())
          52  +
    /* JsonSerializerGenerator.kt:358 */
          53  +
}
          54  +
          55  +
/* JsonParserGenerator.kt:516 */
          56  +
pub(crate) fn de_nested_payload<'a, I>(
          57  +
    tokens: &mut ::std::iter::Peekable<I>,
          58  +
) -> ::std::result::Result<
          59  +
    Option<crate::model::NestedPayload>,
          60  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          61  +
>
          62  +
where
          63  +
    I: Iterator<
          64  +
        Item = Result<
          65  +
            ::aws_smithy_json::deserialize::Token<'a>,
          66  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          67  +
        >,
          68  +
    >,
          69  +
{
          70  +
    /* JsonParserGenerator.kt:712 */
          71  +
    match tokens.next().transpose()? {
          72  +
        /* JsonParserGenerator.kt:713 */
          73  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          74  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          75  +
            /* RustType.kt:534 */
          76  +
            #[allow(unused_mut)]
          77  +
            /* JsonParserGenerator.kt:526 */
          78  +
            let mut builder = crate::model::nested_payload::Builder::default();
          79  +
            /* JsonParserGenerator.kt:684 */
          80  +
            loop {
          81  +
                /* JsonParserGenerator.kt:685 */
          82  +
                match tokens.next().transpose()? {
          83  +
                    /* JsonParserGenerator.kt:686 */
          84  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          85  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          86  +
                        /* JsonParserGenerator.kt:260 */
          87  +
                        match key.to_unescaped()?.as_ref() {
          88  +
                            /* JsonParserGenerator.kt:262 */
          89  +
                            "greeting" => {
          90  +
                                /* JsonParserGenerator.kt:272 */
          91  +
                                builder = builder.set_greeting(
          92  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          93  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          94  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          95  +
                                        /* JsonParserGenerator.kt:339 */)
          96  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          97  +
                                /* JsonParserGenerator.kt:272 */);
          98  +
                                /* JsonParserGenerator.kt:262 */
          99  +
                            }
         100  +
                            /* JsonParserGenerator.kt:262 */
         101  +
                            "name" => {
         102  +
                                /* JsonParserGenerator.kt:272 */
         103  +
                                builder = builder.set_name(
         104  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
         105  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         106  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
         107  +
                                        /* JsonParserGenerator.kt:339 */)
         108  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
         109  +
                                /* JsonParserGenerator.kt:272 */);
         110  +
                                /* JsonParserGenerator.kt:262 */
         111  +
                            }
         112  +
                            /* JsonParserGenerator.kt:290 */
         113  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         114  +
                        }
         115  +
                        /* JsonParserGenerator.kt:686 */
         116  +
                    }
         117  +
                    /* JsonParserGenerator.kt:695 */
         118  +
                    other => {
         119  +
                        return Err(
         120  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         121  +
                                format!("expected object key or end object, found: {other:?}"),
         122  +
                            ),
         123  +
                        )
         124  +
                    } /* JsonParserGenerator.kt:685 */
         125  +
                }
         126  +
                /* JsonParserGenerator.kt:684 */
         127  +
            }
         128  +
            /* JsonParserGenerator.kt:540 */
         129  +
            Ok(Some(builder.build()))
         130  +
            /* JsonParserGenerator.kt:713 */
         131  +
        }
         132  +
        /* JsonParserGenerator.kt:722 */
         133  +
        _ => {
         134  +
            /* JsonParserGenerator.kt:723 */
         135  +
            Err(
         136  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         137  +
                    "expected start object or null",
         138  +
                ),
         139  +
            )
         140  +
            /* JsonParserGenerator.kt:722 */
         141  +
        } /* JsonParserGenerator.kt:712 */
         142  +
    }
         143  +
    /* JsonParserGenerator.kt:516 */
         144  +
}