Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,149 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_json_maps_output_output_output(
           4  +
    value: &crate::output::JsonMapsOutput,
           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_json_maps_output::ser_json_maps_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_json_maps_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::JsonMapsOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
          23  +
    if let Some(var_1) = &input.dense_boolean_map {
          24  +
        /* JsonSerializerGenerator.kt:495 */
          25  +
        #[allow(unused_mut)]
          26  +
        /* JsonSerializerGenerator.kt:496 */
          27  +
        let mut object_2 = object.key("denseBooleanMap").start_object();
          28  +
        /* JsonSerializerGenerator.kt:537 */
          29  +
        for (key_3, value_4) in var_1 {
          30  +
            /* SerializerUtil.kt:42 */
          31  +
            {
          32  +
                /* JsonSerializerGenerator.kt:424 */
          33  +
                object_2.key(key_3.as_str()).boolean(*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:382 */
          43  +
    if let Some(var_5) = &input.dense_number_map {
          44  +
        /* JsonSerializerGenerator.kt:495 */
          45  +
        #[allow(unused_mut)]
          46  +
        /* JsonSerializerGenerator.kt:496 */
          47  +
        let mut object_6 = object.key("denseNumberMap").start_object();
          48  +
        /* JsonSerializerGenerator.kt:537 */
          49  +
        for (key_7, value_8) in var_5 {
          50  +
            /* SerializerUtil.kt:42 */
          51  +
            {
          52  +
                /* JsonSerializerGenerator.kt:432 */
          53  +
                object_6.key(key_7.as_str()).number(
          54  +
                    #[allow(clippy::useless_conversion)]
          55  +
                    ::aws_smithy_types::Number::NegInt((*value_8).into()),
          56  +
                );
          57  +
                /* SerializerUtil.kt:42 */
          58  +
            }
          59  +
            /* JsonSerializerGenerator.kt:537 */
          60  +
        }
          61  +
        /* JsonSerializerGenerator.kt:515 */
          62  +
        object_6.finish();
          63  +
        /* JsonSerializerGenerator.kt:382 */
          64  +
    }
          65  +
    /* JsonSerializerGenerator.kt:382 */
          66  +
    if let Some(var_9) = &input.dense_set_map {
          67  +
        /* JsonSerializerGenerator.kt:495 */
          68  +
        #[allow(unused_mut)]
          69  +
        /* JsonSerializerGenerator.kt:496 */
          70  +
        let mut object_10 = object.key("denseSetMap").start_object();
          71  +
        /* JsonSerializerGenerator.kt:537 */
          72  +
        for (key_11, value_12) in var_9 {
          73  +
            /* SerializerUtil.kt:42 */
          74  +
            {
          75  +
                /* JsonSerializerGenerator.kt:484 */
          76  +
                let mut array_13 = object_10.key(key_11.as_str()).start_array();
          77  +
                /* JsonSerializerGenerator.kt:524 */
          78  +
                for item_14 in &value_12.0 {
          79  +
                    /* SerializerUtil.kt:42 */
          80  +
                    {
          81  +
                        /* JsonSerializerGenerator.kt:423 */
          82  +
                        array_13.value().string(item_14.as_str());
          83  +
                        /* SerializerUtil.kt:42 */
          84  +
                    }
          85  +
                    /* JsonSerializerGenerator.kt:524 */
          86  +
                }
          87  +
                /* JsonSerializerGenerator.kt:486 */
          88  +
                array_13.finish();
          89  +
                /* SerializerUtil.kt:42 */
          90  +
            }
          91  +
            /* JsonSerializerGenerator.kt:537 */
          92  +
        }
          93  +
        /* JsonSerializerGenerator.kt:515 */
          94  +
        object_10.finish();
          95  +
        /* JsonSerializerGenerator.kt:382 */
          96  +
    }
          97  +
    /* JsonSerializerGenerator.kt:382 */
          98  +
    if let Some(var_15) = &input.dense_string_map {
          99  +
        /* JsonSerializerGenerator.kt:495 */
         100  +
        #[allow(unused_mut)]
         101  +
        /* JsonSerializerGenerator.kt:496 */
         102  +
        let mut object_16 = object.key("denseStringMap").start_object();
         103  +
        /* JsonSerializerGenerator.kt:537 */
         104  +
        for (key_17, value_18) in var_15 {
         105  +
            /* SerializerUtil.kt:42 */
         106  +
            {
         107  +
                /* JsonSerializerGenerator.kt:423 */
         108  +
                object_16.key(key_17.as_str()).string(value_18.as_str());
         109  +
                /* SerializerUtil.kt:42 */
         110  +
            }
         111  +
            /* JsonSerializerGenerator.kt:537 */
         112  +
        }
         113  +
        /* JsonSerializerGenerator.kt:515 */
         114  +
        object_16.finish();
         115  +
        /* JsonSerializerGenerator.kt:382 */
         116  +
    }
         117  +
    /* JsonSerializerGenerator.kt:382 */
         118  +
    if let Some(var_19) = &input.dense_struct_map {
         119  +
        /* JsonSerializerGenerator.kt:495 */
         120  +
        #[allow(unused_mut)]
         121  +
        /* JsonSerializerGenerator.kt:496 */
         122  +
        let mut object_20 = object.key("denseStructMap").start_object();
         123  +
        /* JsonSerializerGenerator.kt:537 */
         124  +
        for (key_21, value_22) in var_19 {
         125  +
            /* SerializerUtil.kt:42 */
         126  +
            {
         127  +
                /* JsonSerializerGenerator.kt:495 */
         128  +
                #[allow(unused_mut)]
         129  +
                /* JsonSerializerGenerator.kt:496 */
         130  +
                let mut object_23 = object_20.key(key_21.as_str()).start_object();
         131  +
                /* JsonSerializerGenerator.kt:375 */
         132  +
                crate::protocol_serde::shape_greeting_struct::ser_greeting_struct(
         133  +
                    &mut object_23,
         134  +
                    value_22,
         135  +
                )?;
         136  +
                /* JsonSerializerGenerator.kt:515 */
         137  +
                object_23.finish();
         138  +
                /* SerializerUtil.kt:42 */
         139  +
            }
         140  +
            /* JsonSerializerGenerator.kt:537 */
         141  +
        }
         142  +
        /* JsonSerializerGenerator.kt:515 */
         143  +
        object_20.finish();
         144  +
        /* JsonSerializerGenerator.kt:382 */
         145  +
    }
         146  +
    /* JsonSerializerGenerator.kt:372 */
         147  +
    Ok(())
         148  +
    /* JsonSerializerGenerator.kt:358 */
         149  +
}

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

@@ -0,1 +0,231 @@
           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_json_timestamps_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::JsonTimestampsInput,
           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::json_timestamps_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_json_timestamps::de_json_timestamps(
          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_json_timestamps_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::JsonTimestampsOutput,
          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_json_timestamps_output::ser_json_timestamps_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_json_timestamps(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::json_timestamps_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::json_timestamps_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  +
                    "dateTime" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_date_time(
         122  +
                            /* JsonParserGenerator.kt:384 */
         123  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         124  +
                                tokens.next(),
         125  +
                                ::aws_smithy_types::date_time::Format::DateTime,
         126  +
                            )?, /* JsonParserGenerator.kt:272 */
         127  +
                        );
         128  +
                        /* JsonParserGenerator.kt:262 */
         129  +
                    }
         130  +
                    /* JsonParserGenerator.kt:262 */
         131  +
                    "dateTimeOnTarget" => {
         132  +
                        /* JsonParserGenerator.kt:272 */
         133  +
                        builder = builder.set_date_time_on_target(
         134  +
                            /* JsonParserGenerator.kt:384 */
         135  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         136  +
                                tokens.next(),
         137  +
                                ::aws_smithy_types::date_time::Format::DateTime,
         138  +
                            )?, /* JsonParserGenerator.kt:272 */
         139  +
                        );
         140  +
                        /* JsonParserGenerator.kt:262 */
         141  +
                    }
         142  +
                    /* JsonParserGenerator.kt:262 */
         143  +
                    "epochSeconds" => {
         144  +
                        /* JsonParserGenerator.kt:272 */
         145  +
                        builder = builder.set_epoch_seconds(
         146  +
                            /* JsonParserGenerator.kt:384 */
         147  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         148  +
                                tokens.next(),
         149  +
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
         150  +
                            )?, /* JsonParserGenerator.kt:272 */
         151  +
                        );
         152  +
                        /* JsonParserGenerator.kt:262 */
         153  +
                    }
         154  +
                    /* JsonParserGenerator.kt:262 */
         155  +
                    "epochSecondsOnTarget" => {
         156  +
                        /* JsonParserGenerator.kt:272 */
         157  +
                        builder = builder.set_epoch_seconds_on_target(
         158  +
                            /* JsonParserGenerator.kt:384 */
         159  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         160  +
                                tokens.next(),
         161  +
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
         162  +
                            )?, /* JsonParserGenerator.kt:272 */
         163  +
                        );
         164  +
                        /* JsonParserGenerator.kt:262 */
         165  +
                    }
         166  +
                    /* JsonParserGenerator.kt:262 */
         167  +
                    "httpDate" => {
         168  +
                        /* JsonParserGenerator.kt:272 */
         169  +
                        builder = builder.set_http_date(
         170  +
                            /* JsonParserGenerator.kt:384 */
         171  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         172  +
                                tokens.next(),
         173  +
                                ::aws_smithy_types::date_time::Format::HttpDate,
         174  +
                            )?, /* JsonParserGenerator.kt:272 */
         175  +
                        );
         176  +
                        /* JsonParserGenerator.kt:262 */
         177  +
                    }
         178  +
                    /* JsonParserGenerator.kt:262 */
         179  +
                    "httpDateOnTarget" => {
         180  +
                        /* JsonParserGenerator.kt:272 */
         181  +
                        builder = builder.set_http_date_on_target(
         182  +
                            /* JsonParserGenerator.kt:384 */
         183  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         184  +
                                tokens.next(),
         185  +
                                ::aws_smithy_types::date_time::Format::HttpDate,
         186  +
                            )?, /* JsonParserGenerator.kt:272 */
         187  +
                        );
         188  +
                        /* JsonParserGenerator.kt:262 */
         189  +
                    }
         190  +
                    /* JsonParserGenerator.kt:262 */
         191  +
                    "normal" => {
         192  +
                        /* JsonParserGenerator.kt:272 */
         193  +
                        builder = builder.set_normal(
         194  +
                            /* JsonParserGenerator.kt:384 */
         195  +
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
         196  +
                                tokens.next(),
         197  +
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
         198  +
                            )?, /* JsonParserGenerator.kt:272 */
         199  +
                        );
         200  +
                        /* JsonParserGenerator.kt:262 */
         201  +
                    }
         202  +
                    /* JsonParserGenerator.kt:290 */
         203  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         204  +
                }
         205  +
                /* JsonParserGenerator.kt:686 */
         206  +
            }
         207  +
            /* JsonParserGenerator.kt:695 */
         208  +
            other => {
         209  +
                return Err(
         210  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         211  +
                        "expected object key or end object, found: {other:?}"
         212  +
                    )),
         213  +
                )
         214  +
            } /* JsonParserGenerator.kt:685 */
         215  +
        }
         216  +
        /* JsonParserGenerator.kt:684 */
         217  +
    }
         218  +
    /* JsonParserGenerator.kt:250 */
         219  +
    if tokens.next().is_some() {
         220  +
        /* JsonParserGenerator.kt:251 */
         221  +
        return Err(
         222  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         223  +
                "found more JSON tokens after completing parsing",
         224  +
            ),
         225  +
        );
         226  +
        /* JsonParserGenerator.kt:250 */
         227  +
    }
         228  +
    /* JsonParserGenerator.kt:163 */
         229  +
    Ok(builder)
         230  +
    /* JsonParserGenerator.kt:148 */
         231  +
}

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

@@ -0,1 +0,84 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_json_timestamps_output_output_output(
           4  +
    value: &crate::output::JsonTimestampsOutput,
           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_json_timestamps_output::ser_json_timestamps_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_json_timestamps_output_output(
          22  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    input: &crate::output::JsonTimestampsOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
          26  +
    if let Some(var_1) = &input.date_time {
          27  +
        /* JsonSerializerGenerator.kt:448 */
          28  +
        object
          29  +
            .key("dateTime")
          30  +
            .date_time(var_1, ::aws_smithy_types::date_time::Format::DateTime)?;
          31  +
        /* JsonSerializerGenerator.kt:382 */
          32  +
    }
          33  +
    /* JsonSerializerGenerator.kt:382 */
          34  +
    if let Some(var_2) = &input.date_time_on_target {
          35  +
        /* JsonSerializerGenerator.kt:448 */
          36  +
        object
          37  +
            .key("dateTimeOnTarget")
          38  +
            .date_time(var_2, ::aws_smithy_types::date_time::Format::DateTime)?;
          39  +
        /* JsonSerializerGenerator.kt:382 */
          40  +
    }
          41  +
    /* JsonSerializerGenerator.kt:382 */
          42  +
    if let Some(var_3) = &input.epoch_seconds {
          43  +
        /* JsonSerializerGenerator.kt:448 */
          44  +
        object
          45  +
            .key("epochSeconds")
          46  +
            .date_time(var_3, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          47  +
        /* JsonSerializerGenerator.kt:382 */
          48  +
    }
          49  +
    /* JsonSerializerGenerator.kt:382 */
          50  +
    if let Some(var_4) = &input.epoch_seconds_on_target {
          51  +
        /* JsonSerializerGenerator.kt:448 */
          52  +
        object
          53  +
            .key("epochSecondsOnTarget")
          54  +
            .date_time(var_4, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          55  +
        /* JsonSerializerGenerator.kt:382 */
          56  +
    }
          57  +
    /* JsonSerializerGenerator.kt:382 */
          58  +
    if let Some(var_5) = &input.http_date {
          59  +
        /* JsonSerializerGenerator.kt:448 */
          60  +
        object
          61  +
            .key("httpDate")
          62  +
            .date_time(var_5, ::aws_smithy_types::date_time::Format::HttpDate)?;
          63  +
        /* JsonSerializerGenerator.kt:382 */
          64  +
    }
          65  +
    /* JsonSerializerGenerator.kt:382 */
          66  +
    if let Some(var_6) = &input.http_date_on_target {
          67  +
        /* JsonSerializerGenerator.kt:448 */
          68  +
        object
          69  +
            .key("httpDateOnTarget")
          70  +
            .date_time(var_6, ::aws_smithy_types::date_time::Format::HttpDate)?;
          71  +
        /* JsonSerializerGenerator.kt:382 */
          72  +
    }
          73  +
    /* JsonSerializerGenerator.kt:382 */
          74  +
    if let Some(var_7) = &input.normal {
          75  +
        /* JsonSerializerGenerator.kt:448 */
          76  +
        object
          77  +
            .key("normal")
          78  +
            .date_time(var_7, ::aws_smithy_types::date_time::Format::EpochSeconds)?;
          79  +
        /* JsonSerializerGenerator.kt:382 */
          80  +
    }
          81  +
    /* JsonSerializerGenerator.kt:372 */
          82  +
    Ok(())
          83  +
    /* JsonSerializerGenerator.kt:358 */
          84  +
}

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

@@ -0,1 +0,205 @@
           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_json_unions_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::JsonUnionsInput,
           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::json_unions_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 =
          39  +
                crate::protocol_serde::shape_json_unions::de_json_unions(bytes.as_ref(), input)?;
          40  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          41  +
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          43  +
        input.build()?
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          45  +
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          47  +
}
          48  +
          49  +
/* RustType.kt:534 */
          50  +
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          52  +
pub fn ser_json_unions_http_response(
          53  +
    #[allow(unused_variables)] output: crate::output::JsonUnionsOutput,
          54  +
) -> std::result::Result<
          55  +
    ::aws_smithy_legacy_http_server::response::Response,
          56  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          57  +
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          59  +
    Ok({
          60  +
        /* RustType.kt:534 */
          61  +
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          63  +
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          65  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          66  +
            builder,
          67  +
            ::http::header::CONTENT_TYPE,
          68  +
            "application/json",
          69  +
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          71  +
        let http_status: u16 = 200;
          72  +
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          74  +
        let payload =
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_json_unions_output::ser_json_unions_output_output_output(&output)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          78  +
        let content_length = payload.len();
          79  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
            builder,
          81  +
            ::http::header::CONTENT_LENGTH,
          82  +
            content_length,
          83  +
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          85  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          87  +
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          89  +
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          91  +
}
          92  +
          93  +
/* RustType.kt:534 */
          94  +
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          96  +
pub fn ser_json_unions_http_error(
          97  +
    error: &crate::error::JsonUnionsError,
          98  +
) -> std::result::Result<
          99  +
    ::aws_smithy_legacy_http_server::response::Response,
         100  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         101  +
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         103  +
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         105  +
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         107  +
            crate::error::JsonUnionsError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         109  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:534 */
         111  +
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         113  +
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::CONTENT_TYPE,
         118  +
                    "application/json",
         119  +
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         121  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         122  +
                    builder,
         123  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         124  +
                    "ValidationException",
         125  +
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         127  +
                let content_length = payload.len();
         128  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         129  +
                    builder,
         130  +
                    ::http::header::CONTENT_LENGTH,
         131  +
                    content_length,
         132  +
                );
         133  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         134  +
                builder
         135  +
                    .status(400)
         136  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         138  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         139  +
        }
         140  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         141  +
    })
         142  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         143  +
}
         144  +
         145  +
/* JsonParserGenerator.kt:148 */
         146  +
pub(crate) fn de_json_unions(
         147  +
    value: &[u8],
         148  +
    mut builder: crate::input::json_unions_input::Builder,
         149  +
) -> ::std::result::Result<
         150  +
    crate::input::json_unions_input::Builder,
         151  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         152  +
> {
         153  +
    /* JsonParserGenerator.kt:153 */
         154  +
    let mut tokens_owned =
         155  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         156  +
            .peekable();
         157  +
    let tokens = &mut tokens_owned;
         158  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         159  +
    /* JsonParserGenerator.kt:684 */
         160  +
    loop {
         161  +
        /* JsonParserGenerator.kt:685 */
         162  +
        match tokens.next().transpose()? {
         163  +
            /* JsonParserGenerator.kt:686 */
         164  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         165  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         166  +
                /* JsonParserGenerator.kt:260 */
         167  +
                match key.to_unescaped()?.as_ref() {
         168  +
                    /* JsonParserGenerator.kt:262 */
         169  +
                    "contents" => {
         170  +
                        /* JsonParserGenerator.kt:272 */
         171  +
                        builder = builder.set_contents(
         172  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_my_union::de_my_union(tokens)?
         173  +
                        /* JsonParserGenerator.kt:272 */);
         174  +
                        /* JsonParserGenerator.kt:262 */
         175  +
                    }
         176  +
                    /* JsonParserGenerator.kt:290 */
         177  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         178  +
                }
         179  +
                /* JsonParserGenerator.kt:686 */
         180  +
            }
         181  +
            /* JsonParserGenerator.kt:695 */
         182  +
            other => {
         183  +
                return Err(
         184  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         185  +
                        "expected object key or end object, found: {other:?}"
         186  +
                    )),
         187  +
                )
         188  +
            } /* JsonParserGenerator.kt:685 */
         189  +
        }
         190  +
        /* JsonParserGenerator.kt:684 */
         191  +
    }
         192  +
    /* JsonParserGenerator.kt:250 */
         193  +
    if tokens.next().is_some() {
         194  +
        /* JsonParserGenerator.kt:251 */
         195  +
        return Err(
         196  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         197  +
                "found more JSON tokens after completing parsing",
         198  +
            ),
         199  +
        );
         200  +
        /* JsonParserGenerator.kt:250 */
         201  +
    }
         202  +
    /* JsonParserGenerator.kt:163 */
         203  +
    Ok(builder)
         204  +
    /* JsonParserGenerator.kt:148 */
         205  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_json_unions_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_json_unions_output_output_output(
           4  +
    value: &crate::output::JsonUnionsOutput,
           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_json_unions_output::ser_json_unions_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_json_unions_output_output(
          22  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    input: &crate::output::JsonUnionsOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
          26  +
    if let Some(var_1) = &input.contents {
          27  +
        /* JsonSerializerGenerator.kt:495 */
          28  +
        #[allow(unused_mut)]
          29  +
        /* JsonSerializerGenerator.kt:496 */
          30  +
        let mut object_2 = object.key("contents").start_object();
          31  +
        /* JsonSerializerGenerator.kt:579 */
          32  +
        crate::protocol_serde::shape_my_union::ser_my_union(&mut object_2, var_1)?;
          33  +
        /* JsonSerializerGenerator.kt:515 */
          34  +
        object_2.finish();
          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_malformed_accept_with_body.rs

@@ -0,1 +0,82 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_malformed_accept_with_body_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedAcceptWithBodyInput,
           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_accept_with_body_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:873 */
          30  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          31  +
            &headers, None,
          32  +
        )?;
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          34  +
        input.build()
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          36  +
    })
          37  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          38  +
}
          39  +
          40  +
/* RustType.kt:534 */
          41  +
#[allow(clippy::unnecessary_wraps)]
          42  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          43  +
pub fn ser_malformed_accept_with_body_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::MalformedAcceptWithBodyOutput,
          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:235 */crate::protocol_serde::shape_malformed_accept_with_body_output::ser_malformed_accept_with_body_output_output_output(&output)?
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          69  +
        let content_length = payload.len();
          70  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          71  +
            builder,
          72  +
            ::http::header::CONTENT_LENGTH,
          73  +
            content_length,
          74  +
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          76  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          78  +
        builder.body(body)?
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          80  +
    })
          81  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          82  +
}

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

@@ -0,1 +0,31 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_malformed_accept_with_body_output_output_output(
           4  +
    value: &crate::output::MalformedAcceptWithBodyOutput,
           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_malformed_accept_with_body_output::ser_malformed_accept_with_body_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_malformed_accept_with_body_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::MalformedAcceptWithBodyOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
          23  +
    if let Some(var_1) = &input.hi {
          24  +
        /* JsonSerializerGenerator.kt:423 */
          25  +
        object.key("hi").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
          27  +
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
          29  +
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
          31  +
}

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

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

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

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

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

@@ -0,1 +0,82 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
           3  +
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
           5  +
pub async fn de_malformed_accept_with_payload_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::MalformedAcceptWithPayloadInput,
           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_accept_with_payload_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:873 */
          30  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          31  +
            &headers, None,
          32  +
        )?;
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          34  +
        input.build()
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          36  +
    })
          37  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          38  +
}
          39  +
          40  +
/* RustType.kt:534 */
          41  +
#[allow(clippy::unnecessary_wraps)]
          42  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          43  +
pub fn ser_malformed_accept_with_payload_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::MalformedAcceptWithPayloadOutput,
          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  +
            "image/jpeg",
          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:348 */crate::protocol_serde::shape_malformed_accept_with_payload_output::ser_payload_http_payload( output.payload)?
          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  +
}