Server Test

Server Test

rev. 7254d43655ed63111c94f599437f2b0d3f55446e (ignoring whitespace)

Files changed:

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

@@ -1,1 +95,107 @@
    8      8   
pub(crate) mod shape_content_type_parameters;
    9      9   
   10     10   
pub(crate) mod shape_datetime_offsets;
   11     11   
   12     12   
pub(crate) mod shape_document_type;
   13     13   
   14     14   
pub(crate) mod shape_document_type_as_map_value;
   15     15   
   16     16   
pub(crate) mod shape_document_type_as_payload;
   17     17   
          18  +
pub(crate) mod shape_duplex_stream;
          19  +
          20  +
pub(crate) mod shape_duplex_stream_with_distinct_streams;
          21  +
          22  +
pub(crate) mod shape_duplex_stream_with_initial_messages;
          23  +
   18     24   
pub(crate) mod shape_empty_input_and_empty_output;
   19     25   
   20     26   
pub(crate) mod shape_endpoint_operation;
   21     27   
   22     28   
pub(crate) mod shape_endpoint_with_host_label_operation;
   23     29   
   24     30   
pub(crate) mod shape_fractional_seconds;
   25     31   
   26     32   
pub(crate) mod shape_greeting_with_errors;
   27     33   
   28     34   
pub(crate) mod shape_host_with_path_operation;
   29     35   
   30     36   
pub(crate) mod shape_http_checksum_required;
   31     37   
   32     38   
pub(crate) mod shape_http_empty_prefix_headers;
   33     39   
   34     40   
pub(crate) mod shape_http_enum_payload;
   35     41   
   36     42   
pub(crate) mod shape_http_payload_traits;
   37     43   
   38     44   
pub(crate) mod shape_http_payload_traits_with_media_type;
   39     45   
   40     46   
pub(crate) mod shape_http_payload_with_structure;
   41     47   
   42     48   
pub(crate) mod shape_http_payload_with_union;
   43     49   
   44     50   
pub(crate) mod shape_http_prefix_headers;
   45     51   
   46     52   
pub(crate) mod shape_http_prefix_headers_in_response;
   47     53   
          54  +
pub(crate) mod shape_http_query_params_only_operation;
          55  +
   48     56   
pub(crate) mod shape_http_request_with_float_labels;
   49     57   
   50     58   
pub(crate) mod shape_http_request_with_greedy_label_in_path;
   51     59   
   52     60   
pub(crate) mod shape_http_request_with_labels;
   53     61   
   54     62   
pub(crate) mod shape_http_request_with_labels_and_timestamp_format;
   55     63   
   56     64   
pub(crate) mod shape_http_request_with_regex_literal;
   57     65   
   58     66   
pub(crate) mod shape_http_response_code;
   59     67   
   60     68   
pub(crate) mod shape_http_string_payload;
   61     69   
   62     70   
pub(crate) mod shape_ignore_query_params_in_response;
   63     71   
   64     72   
pub(crate) mod shape_input_and_output_with_headers;
   65     73   
          74  +
pub(crate) mod shape_input_stream;
          75  +
          76  +
pub(crate) mod shape_input_stream_with_initial_request;
          77  +
   66     78   
pub(crate) mod shape_json_blobs;
   67     79   
   68     80   
pub(crate) mod shape_json_enums;
   69     81   
   70     82   
pub(crate) mod shape_json_int_enums;
   71     83   
   72     84   
pub(crate) mod shape_json_lists;
   73     85   
   74     86   
pub(crate) mod shape_json_maps;
   75     87   
@@ -134,146 +193,209 @@
  154    166   
pub(crate) mod shape_null_and_empty_headers_server;
  155    167   
  156    168   
pub(crate) mod shape_omits_null_serializes_empty_string;
  157    169   
  158    170   
pub(crate) mod shape_omits_serializing_empty_lists;
  159    171   
  160    172   
pub(crate) mod shape_operation_with_defaults;
  161    173   
  162    174   
pub(crate) mod shape_operation_with_nested_structure;
  163    175   
         176  +
pub(crate) mod shape_output_stream;
         177  +
         178  +
pub(crate) mod shape_output_stream_with_initial_response;
         179  +
  164    180   
pub(crate) mod shape_post_player_action;
  165    181   
  166    182   
pub(crate) mod shape_post_union_with_json_name;
  167    183   
  168    184   
pub(crate) mod shape_put_with_content_encoding;
  169    185   
  170    186   
pub(crate) mod shape_query_idempotency_token_auto_fill;
  171    187   
  172    188   
pub(crate) mod shape_query_params_as_string_list_map;
  173    189   
@@ -218,234 +349,379 @@
  238    254   
pub fn serialize_document(input: &::aws_smithy_types::Document) -> ::std::vec::Vec<u8> {
  239    255   
    let mut out = String::new();
  240    256   
    ::aws_smithy_json::serialize::JsonValueWriter::new(&mut out).document(input);
  241    257   
    out.into_bytes()
  242    258   
}
  243    259   
  244    260   
pub(crate) mod shape_document_type_as_payload_output;
  245    261   
  246    262   
pub(crate) mod shape_document_type_output;
  247    263   
         264  +
pub(crate) mod shape_duplex_stream_input;
         265  +
         266  +
pub(crate) mod shape_duplex_stream_with_distinct_streams_input;
         267  +
         268  +
/* JsonSerializerGenerator.kt:274 */
         269  +
pub fn rest_json_unset_union_payload() -> ::std::vec::Vec<u8> {
         270  +
    ::std::vec::Vec::new()
         271  +
}
         272  +
         273  +
pub(crate) mod shape_duplex_stream_with_distinct_streams_output;
         274  +
         275  +
pub(crate) mod shape_duplex_stream_with_initial_messages_input;
         276  +
  248    277   
pub(crate) mod shape_empty_input_and_empty_output_output;
  249    278   
         279  +
pub(crate) mod shape_error_event;
         280  +
  250    281   
pub(crate) mod shape_foo_error;
  251    282   
  252    283   
pub(crate) mod shape_fractional_seconds_output;
  253    284   
  254    285   
pub(crate) mod shape_greeting_with_errors_output;
  255    286   
  256    287   
pub(crate) mod shape_http_checksum_required_output;
  257    288   
  258    289   
pub(crate) mod shape_http_empty_prefix_headers_input;
  259    290   
  260    291   
pub(crate) mod shape_http_empty_prefix_headers_output;
  261    292   
  262    293   
pub(crate) mod shape_http_enum_payload_input;
  263    294   
  264    295   
pub(crate) mod shape_http_enum_payload_output;
  265    296   
  266    297   
pub(crate) mod shape_http_payload_traits_input;
  267    298   
  268    299   
pub(crate) mod shape_http_payload_traits_output;
  269    300   
  270    301   
pub(crate) mod shape_http_payload_traits_with_media_type_input;
  271    302   
  272    303   
pub(crate) mod shape_http_payload_traits_with_media_type_output;
  273    304   
  274    305   
pub(crate) mod shape_http_payload_with_structure_input;
  275    306   
  276    307   
/* JsonSerializerGenerator.kt:262 */
  277    308   
pub fn rest_json_unset_struct_payload() -> ::std::vec::Vec<u8> {
  278    309   
    b"{}"[..].into()
  279    310   
}
  280    311   
  281    312   
pub(crate) mod shape_http_payload_with_structure_output;
  282    313   
  283    314   
pub(crate) mod shape_http_payload_with_union_input;
  284    315   
  285         -
/* JsonSerializerGenerator.kt:274 */
  286         -
pub fn rest_json_unset_union_payload() -> ::std::vec::Vec<u8> {
  287         -
    ::std::vec::Vec::new()
  288         -
}
  289         -
  290    316   
pub(crate) mod shape_http_payload_with_union_output;
  291    317   
  292    318   
pub(crate) mod shape_http_prefix_headers_in_response_output;
  293    319   
  294    320   
pub(crate) mod shape_http_prefix_headers_input;
  295    321   
  296    322   
pub(crate) mod shape_http_prefix_headers_output;
  297    323   
  298    324   
pub(crate) mod shape_http_request_with_float_labels_input;
  299    325   
  300    326   
pub(crate) mod shape_http_request_with_greedy_label_in_path_input;
  301    327   
  302    328   
pub(crate) mod shape_http_request_with_labels_and_timestamp_format_input;
  303    329   
  304    330   
pub(crate) mod shape_http_request_with_labels_input;
  305    331   
  306    332   
pub(crate) mod shape_http_request_with_regex_literal_input;
  307    333   
  308    334   
pub(crate) mod shape_http_response_code_output;
  309    335   
  310    336   
pub(crate) mod shape_http_string_payload_input;
  311    337   
  312    338   
pub(crate) mod shape_http_string_payload_output;
  313    339   
  314    340   
pub(crate) mod shape_ignore_query_params_in_response_output;
  315    341   
  316    342   
pub(crate) mod shape_input_and_output_with_headers_input;
  317    343   
  318    344   
pub(crate) mod shape_input_and_output_with_headers_output;
  319    345   
         346  +
pub(crate) mod shape_input_stream_input;
         347  +
         348  +
pub(crate) mod shape_input_stream_with_initial_request_input;
         349  +
  320    350   
pub(crate) mod shape_invalid_greeting;
  321    351   
  322    352   
pub(crate) mod shape_json_blobs_output;
  323    353   
  324    354   
pub(crate) mod shape_json_enums_output;
  325    355   
  326    356   
pub(crate) mod shape_json_int_enums_output;
  327    357   
  328    358   
pub(crate) mod shape_json_lists_output;
  329    359   
@@ -390,420 +449,481 @@
  410    440   
pub(crate) mod shape_query_params_as_string_list_map_input;
  411    441   
  412    442   
pub(crate) mod shape_query_precedence_input;
  413    443   
  414    444   
pub(crate) mod shape_recursive_shapes_output;
  415    445   
  416    446   
pub(crate) mod shape_response_code_http_fallback_output;
  417    447   
  418    448   
pub(crate) mod shape_response_code_required_output;
  419    449   
         450  +
pub(crate) mod shape_service_unavailable_error;
         451  +
  420    452   
pub(crate) mod shape_simple_scalar_properties_input;
  421    453   
  422    454   
pub(crate) mod shape_simple_scalar_properties_output;
  423    455   
  424    456   
pub(crate) mod shape_sparse_json_lists_output;
  425    457   
  426    458   
pub(crate) mod shape_sparse_json_maps_output;
  427    459   
  428    460   
pub(crate) mod shape_streaming_traits_input;
  429    461   
@@ -464,496 +0,622 @@
  484    516   
pub(crate) mod shape_document;
  485    517   
  486    518   
pub(crate) mod shape_document_valued_map;
  487    519   
  488    520   
pub(crate) mod shape_foo_enum_list;
  489    521   
  490    522   
pub(crate) mod shape_foo_enum_map;
  491    523   
  492    524   
pub(crate) mod shape_foo_enum_set;
  493    525   
         526  +
pub(crate) mod shape_headers_and_explicit_payload_event;
         527  +
  494    528   
pub(crate) mod shape_integer_enum_list;
  495    529   
  496    530   
pub(crate) mod shape_integer_enum_map;
  497    531   
  498    532   
pub(crate) mod shape_integer_enum_set;
  499    533   
  500    534   
pub(crate) mod shape_integer_list;
  501    535   
  502    536   
pub(crate) mod shape_my_union;
  503    537   
  504    538   
pub(crate) mod shape_nested_payload;
  505    539   
  506    540   
pub(crate) mod shape_nested_string_list;
  507    541   
  508    542   
pub(crate) mod shape_payload_config;
  509    543   
  510    544   
pub(crate) mod shape_player_action;
  511    545   
  512    546   
pub(crate) mod shape_recursive_shapes_input_output_nested1;
  513    547   
  514    548   
pub(crate) mod shape_simple_list;
  515    549   
  516    550   
pub(crate) mod shape_simple_map;
  517    551   
  518    552   
pub(crate) mod shape_simple_union;
  519    553   
  520    554   
pub(crate) mod shape_sparse_boolean_map;
  521    555   
  522    556   
pub(crate) mod shape_sparse_number_map;
  523    557   
  524    558   
pub(crate) mod shape_sparse_set_map;
  525    559   
  526    560   
pub(crate) mod shape_sparse_short_list;
  527    561   
  528    562   
pub(crate) mod shape_sparse_string_list;
  529    563   
  530    564   
pub(crate) mod shape_sparse_string_map;
  531    565   
  532    566   
pub(crate) mod shape_sparse_struct_map;
  533    567   
  534    568   
pub(crate) mod shape_string_list;
  535    569   
  536    570   
pub(crate) mod shape_string_set;
  537    571   
  538    572   
pub(crate) mod shape_structure_list;
  539    573   
         574  +
pub(crate) mod shape_structure_payload_event;
         575  +
  540    576   
pub(crate) mod shape_test_config;
  541    577   
  542    578   
pub(crate) mod shape_timestamp_list;
  543    579   
  544    580   
pub(crate) mod shape_top_level;
  545    581   
  546    582   
pub(crate) mod shape_union_payload;
  547    583   
         584  +
pub(crate) mod shape_union_payload_event;
         585  +
  548    586   
pub(crate) mod shape_union_with_json_name;
  549    587   
  550    588   
pub(crate) mod shape_complex_nested_error_data;
  551    589   
  552    590   
pub(crate) mod shape_dialog;
  553    591   
  554    592   
pub(crate) mod shape_dialog_list;
  555    593   
  556    594   
pub(crate) mod shape_dialog_map;
  557    595   
  558    596   
pub(crate) mod shape_greeting_struct;
  559    597   
         598  +
pub(crate) mod shape_headers_and_implicit_payload_event;
         599  +
         600  +
pub(crate) mod shape_payload_structure;
         601  +
         602  +
pub(crate) mod shape_payload_union;
         603  +
  560    604   
pub(crate) mod shape_recursive_shapes_input_output_nested2;
  561    605   
  562    606   
pub(crate) mod shape_renamed_greeting;
  563    607   
         608  +
pub(crate) mod shape_singleton_event_stream;
         609  +
  564    610   
pub(crate) mod shape_string_map;
  565    611   
  566    612   
pub(crate) mod shape_structure_list_member;
  567    613   
  568    614   
pub(crate) mod shape_test_string_list;
  569    615   
  570    616   
pub(crate) mod shape_test_string_map;
  571    617   
  572    618   
pub(crate) mod shape_validation_exception_field;
  573    619   
  574    620   
pub(crate) mod shape_farewell;
         621  +
         622  +
pub(crate) mod shape_singleton_event;

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

@@ -0,1 +0,187 @@
           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:412 */
           5  +
pub async fn de_duplex_stream_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DuplexStreamInput,
           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: Into<::aws_smithy_types::byte_stream::ByteStream>,
          14  +
    B::Data: Send,
          15  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          16  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          17  +
{
          18  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
          19  +
    Ok({
          20  +
        /* RustType.kt:534 */
          21  +
        #[allow(unused_mut)]
          22  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
          23  +
        let mut input = crate::input::duplex_stream_input::Builder::default();
          24  +
        /* RustType.kt:534 */
          25  +
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
          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:870 */
          31  +
        if let Some(value) = {
          32  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_input::de_stream_payload(
          33  +
                &mut body.into().into_inner(),
          34  +
            )?;
          35  +
            if let Some(_initial_event) = receiver
          36  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          37  +
                                                .await
          38  +
                                                .map_err(
          39  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          40  +
                                                        #[allow(clippy::useless_conversion)]
          41  +
                                                        format!("{ev_error}").into()
          42  +
                                                    )
          43  +
                                                )? {
          44  +
                                                
          45  +
                                            }
          46  +
            Some(receiver)
          47  +
        } {
          48  +
            input = input.set_stream(value)
          49  +
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
          51  +
        input.build()?
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
          53  +
    })
          54  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
          55  +
}
          56  +
          57  +
/* RustType.kt:534 */
          58  +
#[allow(clippy::unnecessary_wraps)]
          59  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
          60  +
pub fn ser_duplex_stream_http_response(
          61  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamOutput,
          62  +
) -> std::result::Result<
          63  +
    ::aws_smithy_legacy_http_server::response::Response,
          64  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          65  +
> {
          66  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
          67  +
    Ok({
          68  +
        /* RustType.kt:534 */
          69  +
        #[allow(unused_mut)]
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
          71  +
        let mut builder = ::http::Response::builder();
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
          73  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          74  +
            builder,
          75  +
            ::http::header::CONTENT_TYPE,
          76  +
            "application/vnd.amazon.eventstream",
          77  +
        );
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
          79  +
        let http_status: u16 = 200;
          80  +
        builder = builder.status(http_status);
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:589 */
          82  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          83  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream(
          84  +
                /* ServerHttpBoundProtocolGenerator.kt:145 */
          85  +
                {
          86  +
                    let error_marshaller =
          87  +
                        crate::event_stream_serde::EventStreamErrorMarshaller::new();
          88  +
                    let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          89  +
                    let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          90  +
                    output
          91  +
                        .stream
          92  +
                        .into_body_stream(marshaller, error_marshaller, signer)
          93  +
                }, /* ServerHttpBoundProtocolGenerator.kt:589 */
          94  +
            ),
          95  +
        );
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
          97  +
        builder.body(body)?
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
          99  +
    })
         100  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
         101  +
}
         102  +
         103  +
/* RustType.kt:534 */
         104  +
#[allow(clippy::unnecessary_wraps)]
         105  +
/* ServerHttpBoundProtocolGenerator.kt:475 */
         106  +
pub fn ser_duplex_stream_http_error(
         107  +
    error: &crate::error::DuplexStreamError,
         108  +
) -> std::result::Result<
         109  +
    ::aws_smithy_legacy_http_server::response::Response,
         110  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         111  +
> {
         112  +
    /* ServerHttpBoundProtocolGenerator.kt:480 */
         113  +
    Ok({
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:496 */
         115  +
        match error {
         116  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         117  +
            crate::error::DuplexStreamError::ValidationException(output) => {
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         119  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         120  +
                /* RustType.kt:534 */
         121  +
                #[allow(unused_mut)]
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         123  +
                let mut builder = ::http::Response::builder();
         124  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         125  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         126  +
                    builder,
         127  +
                    ::http::header::CONTENT_TYPE,
         128  +
                    "application/vnd.amazon.eventstream",
         129  +
                );
         130  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         131  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         132  +
                    builder,
         133  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         134  +
                    "ValidationException",
         135  +
                );
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         137  +
                let content_length = payload.len();
         138  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         139  +
                    builder,
         140  +
                    ::http::header::CONTENT_LENGTH,
         141  +
                    content_length,
         142  +
                );
         143  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         144  +
                builder
         145  +
                    .status(400)
         146  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         148  +
            }
         149  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         150  +
            crate::error::DuplexStreamError::ErrorEvent(output) => {
         151  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         152  +
                let payload =
         153  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         154  +
                /* RustType.kt:534 */
         155  +
                #[allow(unused_mut)]
         156  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         157  +
                let mut builder = ::http::Response::builder();
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         159  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         160  +
                    builder,
         161  +
                    ::http::header::CONTENT_TYPE,
         162  +
                    "application/vnd.amazon.eventstream",
         163  +
                );
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         165  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         166  +
                    builder,
         167  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         168  +
                    "ErrorEvent",
         169  +
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         171  +
                let content_length = payload.len();
         172  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         173  +
                    builder,
         174  +
                    ::http::header::CONTENT_LENGTH,
         175  +
                    content_length,
         176  +
                );
         177  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         178  +
                builder
         179  +
                    .status(400)
         180  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         181  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         182  +
            } /* ServerHttpBoundProtocolGenerator.kt:496 */
         183  +
        }
         184  +
        /* ServerHttpBoundProtocolGenerator.kt:480 */
         185  +
    })
         186  +
    /* ServerHttpBoundProtocolGenerator.kt:475 */
         187  +
}

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

@@ -0,1 +0,19 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:236 */
           3  +
pub fn de_stream_payload(
           4  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           5  +
) -> std::result::Result<
           6  +
    crate::sigv4_event_stream::SigV4Receiver<
           7  +
        crate::model::EventStream,
           8  +
        crate::error::EventStreamError,
           9  +
    >,
          10  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          11  +
> {
          12  +
    /* HttpBindingGenerator.kt:278 */
          13  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
          14  +
    /* HttpBindingGenerator.kt:296 */
          15  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          16  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          17  +
    Ok(receiver)
          18  +
    /* HttpBindingGenerator.kt:236 */
          19  +
}

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

@@ -0,1 +0,183 @@
           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:412 */
           5  +
pub async fn de_duplex_stream_with_distinct_streams_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DuplexStreamWithDistinctStreamsInput,
           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: Into<::aws_smithy_types::byte_stream::ByteStream>,
          14  +
    B::Data: Send,
          15  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          16  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          17  +
{
          18  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
          19  +
    Ok({
          20  +
        /* RustType.kt:534 */
          21  +
        #[allow(unused_mut)]
          22  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
          23  +
        let mut input = crate::input::duplex_stream_with_distinct_streams_input::Builder::default();
          24  +
        /* RustType.kt:534 */
          25  +
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
          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:870 */
          31  +
        if let Some(value) = {
          32  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_with_distinct_streams_input::de_stream_payload(&mut body.into().into_inner())?;
          33  +
            if let Some(_initial_event) = receiver
          34  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          35  +
                                                .await
          36  +
                                                .map_err(
          37  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          38  +
                                                        #[allow(clippy::useless_conversion)]
          39  +
                                                        format!("{ev_error}").into()
          40  +
                                                    )
          41  +
                                                )? {
          42  +
                                                
          43  +
                                            }
          44  +
            Some(receiver)
          45  +
        } {
          46  +
            input = input.set_stream(value)
          47  +
        }
          48  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
          49  +
        input.build()?
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
          51  +
    })
          52  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
          53  +
}
          54  +
          55  +
/* RustType.kt:534 */
          56  +
#[allow(clippy::unnecessary_wraps)]
          57  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
          58  +
pub fn ser_duplex_stream_with_distinct_streams_http_response(
          59  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamWithDistinctStreamsOutput,
          60  +
) -> std::result::Result<
          61  +
    ::aws_smithy_legacy_http_server::response::Response,
          62  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          63  +
> {
          64  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
          65  +
    Ok({
          66  +
        /* RustType.kt:534 */
          67  +
        #[allow(unused_mut)]
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
          69  +
        let mut builder = ::http::Response::builder();
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
          71  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          72  +
            builder,
          73  +
            ::http::header::CONTENT_TYPE,
          74  +
            "application/json",
          75  +
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
          77  +
        let http_status: u16 = 200;
          78  +
        builder = builder.status(http_status);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          80  +
        let payload =
          81  +
            /* HttpBoundProtocolPayloadGenerator.kt:353 */crate::protocol_serde::shape_duplex_stream_with_distinct_streams_output::ser_stream_http_payload(& output.stream)?
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */;
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:713 */
          84  +
        let content_length = payload.len();
          85  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          86  +
            builder,
          87  +
            ::http::header::CONTENT_LENGTH,
          88  +
            content_length,
          89  +
        );
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:617 */
          91  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
          93  +
        builder.body(body)?
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
          95  +
    })
          96  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
          97  +
}
          98  +
          99  +
/* RustType.kt:534 */
         100  +
#[allow(clippy::unnecessary_wraps)]
         101  +
/* ServerHttpBoundProtocolGenerator.kt:475 */
         102  +
pub fn ser_duplex_stream_with_distinct_streams_http_error(
         103  +
    error: &crate::error::DuplexStreamWithDistinctStreamsError,
         104  +
) -> std::result::Result<
         105  +
    ::aws_smithy_legacy_http_server::response::Response,
         106  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         107  +
> {
         108  +
    /* ServerHttpBoundProtocolGenerator.kt:480 */
         109  +
    Ok({
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:496 */
         111  +
        match error {
         112  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         113  +
            crate::error::DuplexStreamWithDistinctStreamsError::ValidationException(output) => {
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         115  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         116  +
                /* RustType.kt:534 */
         117  +
                #[allow(unused_mut)]
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         119  +
                let mut builder = ::http::Response::builder();
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         121  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         122  +
                    builder,
         123  +
                    ::http::header::CONTENT_TYPE,
         124  +
                    "application/json",
         125  +
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         127  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         128  +
                    builder,
         129  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         130  +
                    "ValidationException",
         131  +
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         133  +
                let content_length = payload.len();
         134  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         135  +
                    builder,
         136  +
                    ::http::header::CONTENT_LENGTH,
         137  +
                    content_length,
         138  +
                );
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         140  +
                builder
         141  +
                    .status(400)
         142  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         143  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         144  +
            }
         145  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         146  +
            crate::error::DuplexStreamWithDistinctStreamsError::ErrorEvent(output) => {
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         148  +
                let payload =
         149  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         150  +
                /* RustType.kt:534 */
         151  +
                #[allow(unused_mut)]
         152  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         153  +
                let mut builder = ::http::Response::builder();
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         155  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         156  +
                    builder,
         157  +
                    ::http::header::CONTENT_TYPE,
         158  +
                    "application/json",
         159  +
                );
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         161  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         162  +
                    builder,
         163  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         164  +
                    "ErrorEvent",
         165  +
                );
         166  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         167  +
                let content_length = payload.len();
         168  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         169  +
                    builder,
         170  +
                    ::http::header::CONTENT_LENGTH,
         171  +
                    content_length,
         172  +
                );
         173  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         174  +
                builder
         175  +
                    .status(400)
         176  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         177  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         178  +
            } /* ServerHttpBoundProtocolGenerator.kt:496 */
         179  +
        }
         180  +
        /* ServerHttpBoundProtocolGenerator.kt:480 */
         181  +
    })
         182  +
    /* ServerHttpBoundProtocolGenerator.kt:475 */
         183  +
}

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

@@ -0,1 +0,19 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:236 */
           3  +
pub fn de_stream_payload(
           4  +
    body: &mut ::aws_smithy_types::body::SdkBody,
           5  +
) -> std::result::Result<
           6  +
    crate::sigv4_event_stream::SigV4Receiver<
           7  +
        crate::model::EventStream,
           8  +
        crate::error::EventStreamError,
           9  +
    >,
          10  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          11  +
> {
          12  +
    /* HttpBindingGenerator.kt:278 */
          13  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
          14  +
    /* HttpBindingGenerator.kt:296 */
          15  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          16  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          17  +
    Ok(receiver)
          18  +
    /* HttpBindingGenerator.kt:236 */
          19  +
}

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

@@ -0,1 +0,44 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:314 */
           3  +
pub fn ser_stream_http_payload(
           4  +
    payload: &::std::option::Option<crate::model::SingletonEventStream>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:323 */
           7  +
    let payload = match payload.as_ref() {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:342 */
          12  +
                crate::protocol_serde::rest_json_unset_union_payload(), /* HttpBoundProtocolPayloadGenerator.kt:323 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:348 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:389 */crate::protocol_serde::shape_duplex_stream_with_distinct_streams_output::ser_stream_payload(payload)?
          19  +
    /* HttpBoundProtocolPayloadGenerator.kt:348 */)
          20  +
    /* HttpBoundProtocolPayloadGenerator.kt:314 */
          21  +
}
          22  +
          23  +
/* JsonSerializerGenerator.kt:242 */
          24  +
pub fn ser_stream_payload(
          25  +
    input: &crate::model::SingletonEventStream,
          26  +
) -> std::result::Result<
          27  +
    ::std::vec::Vec<u8>,
          28  +
    ::aws_smithy_types::error::operation::SerializationError,
          29  +
> {
          30  +
    /* JsonSerializerGenerator.kt:247 */
          31  +
    let mut out = String::new();
          32  +
    /* JsonSerializerGenerator.kt:248 */
          33  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          34  +
    /* JsonSerializerGenerator.kt:591 */
          35  +
    crate::protocol_serde::shape_singleton_event_stream::ser_singleton_event_stream(
          36  +
        &mut object,
          37  +
        input,
          38  +
    )?;
          39  +
    /* JsonSerializerGenerator.kt:254 */
          40  +
    object.finish();
          41  +
    /* JsonSerializerGenerator.kt:255 */
          42  +
    Ok(out.into_bytes())
          43  +
    /* JsonSerializerGenerator.kt:242 */
          44  +
}

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

@@ -0,1 +0,257 @@
           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:412 */
           5  +
pub async fn de_duplex_stream_with_initial_messages_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::DuplexStreamWithInitialMessagesInput,
           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: Into<::aws_smithy_types::byte_stream::ByteStream>,
          14  +
    B::Data: Send,
          15  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          16  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          17  +
{
          18  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
          19  +
    Ok({
          20  +
        /* RustType.kt:534 */
          21  +
        #[allow(unused_mut)]
          22  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
          23  +
        let mut input = crate::input::duplex_stream_with_initial_messages_input::Builder::default();
          24  +
        /* RustType.kt:534 */
          25  +
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
          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:870 */
          31  +
        if let Some(value) = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_initial_request_member_header(&headers)? {
          32  +
                                input = input.set_initial_request_member(value)
          33  +
                            }
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:870 */
          35  +
        if let Some(value) = {
          36  +
            let mut receiver = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_stream_payload(&mut body.into().into_inner())?;
          37  +
            if let Some(_initial_event) = receiver
          38  +
                                                .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
          39  +
                                                .await
          40  +
                                                .map_err(
          41  +
                                                    |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
          42  +
                                                        #[allow(clippy::useless_conversion)]
          43  +
                                                        format!("{ev_error}").into()
          44  +
                                                    )
          45  +
                                                )? {
          46  +
                                                
          47  +
                                            }
          48  +
            Some(receiver)
          49  +
        } {
          50  +
            input = input.set_stream(value)
          51  +
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
          53  +
        input.build()?
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
          55  +
    })
          56  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
          57  +
}
          58  +
          59  +
/* RustType.kt:534 */
          60  +
#[allow(clippy::unnecessary_wraps)]
          61  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
          62  +
pub fn ser_duplex_stream_with_initial_messages_http_response(
          63  +
    #[allow(unused_variables)] output: crate::output::DuplexStreamWithInitialMessagesOutput,
          64  +
) -> std::result::Result<
          65  +
    ::aws_smithy_legacy_http_server::response::Response,
          66  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          67  +
> {
          68  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
          69  +
    Ok({
          70  +
        /* RustType.kt:534 */
          71  +
        #[allow(unused_mut)]
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
          73  +
        let mut builder = ::http::Response::builder();
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:679 */
          75  +
        builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(&output, builder)?;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
          77  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          78  +
            builder,
          79  +
            ::http::header::CONTENT_TYPE,
          80  +
            "application/vnd.amazon.eventstream",
          81  +
        );
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
          83  +
        let http_status: u16 = 200;
          84  +
        builder = builder.status(http_status);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:589 */
          86  +
        let body = ::aws_smithy_legacy_http_server::body::boxed(
          87  +
            ::aws_smithy_legacy_http_server::body::Body::wrap_stream(
          88  +
                /* ServerHttpBoundProtocolGenerator.kt:145 */
          89  +
                {
          90  +
                    let error_marshaller =
          91  +
                        crate::event_stream_serde::EventStreamErrorMarshaller::new();
          92  +
                    let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          93  +
                    let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          94  +
                    output
          95  +
                        .stream
          96  +
                        .into_body_stream(marshaller, error_marshaller, signer)
          97  +
                }, /* ServerHttpBoundProtocolGenerator.kt:589 */
          98  +
            ),
          99  +
        );
         100  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
         101  +
        builder.body(body)?
         102  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
         103  +
    })
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
         105  +
}
         106  +
         107  +
/* RustType.kt:534 */
         108  +
#[allow(clippy::unnecessary_wraps)]
         109  +
/* ServerHttpBoundProtocolGenerator.kt:475 */
         110  +
pub fn ser_duplex_stream_with_initial_messages_http_error(
         111  +
    error: &crate::error::DuplexStreamWithInitialMessagesError,
         112  +
) -> std::result::Result<
         113  +
    ::aws_smithy_legacy_http_server::response::Response,
         114  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         115  +
> {
         116  +
    /* ServerHttpBoundProtocolGenerator.kt:480 */
         117  +
    Ok({
         118  +
        /* ServerHttpBoundProtocolGenerator.kt:496 */
         119  +
        match error {
         120  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         121  +
            crate::error::DuplexStreamWithInitialMessagesError::ServiceUnavailableError(output) => {
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         123  +
                let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
         124  +
                /* RustType.kt:534 */
         125  +
                #[allow(unused_mut)]
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         127  +
                let mut builder = ::http::Response::builder();
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         129  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         130  +
                    builder,
         131  +
                    ::http::header::CONTENT_TYPE,
         132  +
                    "application/vnd.amazon.eventstream",
         133  +
                );
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         135  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         136  +
                    builder,
         137  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         138  +
                    "ServiceUnavailableError",
         139  +
                );
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         141  +
                let content_length = payload.len();
         142  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         143  +
                    builder,
         144  +
                    ::http::header::CONTENT_LENGTH,
         145  +
                    content_length,
         146  +
                );
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         148  +
                builder
         149  +
                    .status(500)
         150  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         151  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         152  +
            }
         153  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         154  +
            crate::error::DuplexStreamWithInitialMessagesError::ValidationException(output) => {
         155  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         156  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         157  +
                /* RustType.kt:534 */
         158  +
                #[allow(unused_mut)]
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         160  +
                let mut builder = ::http::Response::builder();
         161  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         162  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         163  +
                    builder,
         164  +
                    ::http::header::CONTENT_TYPE,
         165  +
                    "application/vnd.amazon.eventstream",
         166  +
                );
         167  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         168  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         169  +
                    builder,
         170  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         171  +
                    "ValidationException",
         172  +
                );
         173  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         174  +
                let content_length = payload.len();
         175  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         176  +
                    builder,
         177  +
                    ::http::header::CONTENT_LENGTH,
         178  +
                    content_length,
         179  +
                );
         180  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         181  +
                builder
         182  +
                    .status(400)
         183  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         184  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         185  +
            }
         186  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         187  +
            crate::error::DuplexStreamWithInitialMessagesError::ErrorEvent(output) => {
         188  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         189  +
                let payload =
         190  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         191  +
                /* RustType.kt:534 */
         192  +
                #[allow(unused_mut)]
         193  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         194  +
                let mut builder = ::http::Response::builder();
         195  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         196  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         197  +
                    builder,
         198  +
                    ::http::header::CONTENT_TYPE,
         199  +
                    "application/vnd.amazon.eventstream",
         200  +
                );
         201  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         202  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         203  +
                    builder,
         204  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         205  +
                    "ErrorEvent",
         206  +
                );
         207  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         208  +
                let content_length = payload.len();
         209  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         210  +
                    builder,
         211  +
                    ::http::header::CONTENT_LENGTH,
         212  +
                    content_length,
         213  +
                );
         214  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         215  +
                builder
         216  +
                    .status(400)
         217  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         218  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         219  +
            } /* ServerHttpBoundProtocolGenerator.kt:496 */
         220  +
        }
         221  +
        /* ServerHttpBoundProtocolGenerator.kt:480 */
         222  +
    })
         223  +
    /* ServerHttpBoundProtocolGenerator.kt:475 */
         224  +
}
         225  +
         226  +
/* HttpBindingGenerator.kt:565 */
         227  +
pub fn ser_duplex_stream_with_initial_messages_headers(
         228  +
    input: &crate::output::DuplexStreamWithInitialMessagesOutput,
         229  +
    mut builder: ::http::response::Builder,
         230  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         231  +
{
         232  +
    /* SerializerUtil.kt:42 */
         233  +
    {
         234  +
        /* HttpBindingGenerator.kt:727 */
         235  +
        let formatted_1 = &input.initial_response_member.as_str();
         236  +
        /* HttpBindingGenerator.kt:728 */
         237  +
        if !formatted_1.is_empty() {
         238  +
            /* HttpBindingGenerator.kt:729 */
         239  +
            let header_value = formatted_1;
         240  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         241  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         242  +
                    "initial_response_member",
         243  +
                    format!(
         244  +
                        "`{}` cannot be used as a header value: {}",
         245  +
                        &header_value, err
         246  +
                    ),
         247  +
                )
         248  +
            })?;
         249  +
            builder = builder.header("initial-response-member", header_value);
         250  +
            /* HttpBindingGenerator.kt:728 */
         251  +
        }
         252  +
        /* SerializerUtil.kt:42 */
         253  +
    }
         254  +
    /* HttpBindingGenerator.kt:578 */
         255  +
    Ok(builder)
         256  +
    /* HttpBindingGenerator.kt:565 */
         257  +
}

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

@@ -0,1 +0,33 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
           3  +
pub(crate) fn de_initial_request_member_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("initial-request-member");
          11  +
    /* HttpBindingGenerator.kt:398 */
          12  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:159 */
          14  +
}
          15  +
          16  +
/* HttpBindingGenerator.kt:236 */
          17  +
pub fn de_stream_payload(
          18  +
    body: &mut ::aws_smithy_types::body::SdkBody,
          19  +
) -> std::result::Result<
          20  +
    crate::sigv4_event_stream::SigV4Receiver<
          21  +
        crate::model::EventStream,
          22  +
        crate::error::EventStreamError,
          23  +
    >,
          24  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          25  +
> {
          26  +
    /* HttpBindingGenerator.kt:278 */
          27  +
    let unmarshaller = crate::event_stream_serde::EventStreamUnmarshaller::new();
          28  +
    /* HttpBindingGenerator.kt:296 */
          29  +
    let body = std::mem::replace(body, ::aws_smithy_types::body::SdkBody::taken());
          30  +
    let receiver = crate::sigv4_event_stream::SigV4Receiver::new(unmarshaller, body);
          31  +
    Ok(receiver)
          32  +
    /* HttpBindingGenerator.kt:236 */
          33  +
}

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

@@ -0,1 +0,102 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:215 */
           3  +
pub fn ser_error_event_error(
           4  +
    value: &crate::error::ErrorEvent,
           5  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:220 */
           7  +
    let mut out = ::std::string::String::new();
           8  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:377 */
          10  +
    crate::protocol_serde::shape_error_event::ser_error_event(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:229 */
          12  +
    object.finish();
          13  +
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:215 */
          15  +
}
          16  +
          17  +
/* JsonSerializerGenerator.kt:360 */
          18  +
pub fn ser_error_event(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::error::ErrorEvent,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:384 */
          23  +
    if let Some(var_1) = &input.message {
          24  +
        /* JsonSerializerGenerator.kt:425 */
          25  +
        object.key("message").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:384 */
          27  +
    }
          28  +
    /* JsonSerializerGenerator.kt:374 */
          29  +
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:360 */
          31  +
}
          32  +
          33  +
/* JsonParserGenerator.kt:151 */
          34  +
pub(crate) fn de_error_event_json_err(
          35  +
    _value: &[u8],
          36  +
    mut builder: crate::error::error_event::Builder,
          37  +
) -> ::std::result::Result<
          38  +
    crate::error::error_event::Builder,
          39  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          40  +
> {
          41  +
    /* JsonParserGenerator.kt:158 */
          42  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          43  +
        crate::protocol_serde::or_empty_doc(_value),
          44  +
    )
          45  +
    .peekable();
          46  +
    let tokens = &mut tokens_owned;
          47  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          48  +
    /* JsonParserGenerator.kt:721 */
          49  +
    loop {
          50  +
        /* JsonParserGenerator.kt:722 */
          51  +
        match tokens.next().transpose()? {
          52  +
            /* JsonParserGenerator.kt:723 */
          53  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          54  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          55  +
                /* JsonParserGenerator.kt:265 */
          56  +
                match key.to_unescaped()?.as_ref() {
          57  +
                    /* JsonParserGenerator.kt:267 */
          58  +
                    "message" => {
          59  +
                        /* JsonParserGenerator.kt:277 */
          60  +
                        builder = builder.set_message(
          61  +
                            /* JsonParserGenerator.kt:361 */
          62  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          63  +
                                tokens.next(),
          64  +
                            )?
          65  +
                            .map(|s|
          66  +
                                /* JsonParserGenerator.kt:346 */s.to_unescaped().map(|u|
          67  +
                                    /* JsonParserGenerator.kt:355 */u.into_owned()
          68  +
                                /* JsonParserGenerator.kt:346 */) /* JsonParserGenerator.kt:361 */)
          69  +
                            .transpose()?, /* JsonParserGenerator.kt:277 */
          70  +
                        );
          71  +
                        /* JsonParserGenerator.kt:267 */
          72  +
                    }
          73  +
                    /* JsonParserGenerator.kt:295 */
          74  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:265 */
          75  +
                }
          76  +
                /* JsonParserGenerator.kt:723 */
          77  +
            }
          78  +
            /* JsonParserGenerator.kt:732 */
          79  +
            other => {
          80  +
                return Err(
          81  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          82  +
                        "expected object key or end object, found: {other:?}"
          83  +
                    )),
          84  +
                )
          85  +
            } /* JsonParserGenerator.kt:722 */
          86  +
        }
          87  +
        /* JsonParserGenerator.kt:721 */
          88  +
    }
          89  +
    /* JsonParserGenerator.kt:255 */
          90  +
    if tokens.next().is_some() {
          91  +
        /* JsonParserGenerator.kt:256 */
          92  +
        return Err(
          93  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          94  +
                "found more JSON tokens after completing parsing",
          95  +
            ),
          96  +
        );
          97  +
        /* JsonParserGenerator.kt:255 */
          98  +
    }
          99  +
    /* JsonParserGenerator.kt:168 */
         100  +
    Ok(builder)
         101  +
    /* JsonParserGenerator.kt:151 */
         102  +
}

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

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:242 */
           3  +
pub fn ser_payload_payload(
           4  +
    input: &crate::model::PayloadStructure,
           5  +
) -> std::result::Result<
           6  +
    ::std::vec::Vec<u8>,
           7  +
    ::aws_smithy_types::error::operation::SerializationError,
           8  +
> {
           9  +
    /* JsonSerializerGenerator.kt:247 */
          10  +
    let mut out = String::new();
          11  +
    /* JsonSerializerGenerator.kt:248 */
          12  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          13  +
    /* JsonSerializerGenerator.kt:377 */
          14  +
    crate::protocol_serde::shape_payload_structure::ser_payload_structure(&mut object, input)?;
          15  +
    /* JsonSerializerGenerator.kt:254 */
          16  +
    object.finish();
          17  +
    /* JsonSerializerGenerator.kt:255 */
          18  +
    Ok(out.into_bytes())
          19  +
    /* JsonSerializerGenerator.kt:242 */
          20  +
}

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

@@ -0,1 +0,87 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:151 */
           3  +
pub(crate) fn de_headers_and_implicit_payload_event_json_err(
           4  +
    _value: &[u8],
           5  +
    mut builder: crate::model::headers_and_implicit_payload_event::Builder,
           6  +
) -> ::std::result::Result<
           7  +
    crate::model::headers_and_implicit_payload_event::Builder,
           8  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           9  +
> {
          10  +
    /* JsonParserGenerator.kt:158 */
          11  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          12  +
        crate::protocol_serde::or_empty_doc(_value),
          13  +
    )
          14  +
    .peekable();
          15  +
    let tokens = &mut tokens_owned;
          16  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          17  +
    /* JsonParserGenerator.kt:721 */
          18  +
    loop {
          19  +
        /* JsonParserGenerator.kt:722 */
          20  +
        match tokens.next().transpose()? {
          21  +
            /* JsonParserGenerator.kt:723 */
          22  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          23  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          24  +
                /* JsonParserGenerator.kt:265 */
          25  +
                match key.to_unescaped()?.as_ref() {
          26  +
                    /* JsonParserGenerator.kt:267 */
          27  +
                    "header" => {
          28  +
                        /* JsonParserGenerator.kt:277 */
          29  +
                        builder = builder.set_header(
          30  +
                            /* JsonParserGenerator.kt:361 */
          31  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          32  +
                                tokens.next(),
          33  +
                            )?
          34  +
                            .map(|s|
          35  +
                                /* JsonParserGenerator.kt:346 */s.to_unescaped().map(|u|
          36  +
                                    /* JsonParserGenerator.kt:355 */u.into_owned()
          37  +
                                /* JsonParserGenerator.kt:346 */) /* JsonParserGenerator.kt:361 */)
          38  +
                            .transpose()?, /* JsonParserGenerator.kt:277 */
          39  +
                        );
          40  +
                        /* JsonParserGenerator.kt:267 */
          41  +
                    }
          42  +
                    /* JsonParserGenerator.kt:267 */
          43  +
                    "payload" => {
          44  +
                        /* JsonParserGenerator.kt:277 */
          45  +
                        builder = builder.set_payload(
          46  +
                            /* JsonParserGenerator.kt:361 */
          47  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
          48  +
                                tokens.next(),
          49  +
                            )?
          50  +
                            .map(|s|
          51  +
                                /* JsonParserGenerator.kt:346 */s.to_unescaped().map(|u|
          52  +
                                    /* JsonParserGenerator.kt:355 */u.into_owned()
          53  +
                                /* JsonParserGenerator.kt:346 */) /* JsonParserGenerator.kt:361 */)
          54  +
                            .transpose()?, /* JsonParserGenerator.kt:277 */
          55  +
                        );
          56  +
                        /* JsonParserGenerator.kt:267 */
          57  +
                    }
          58  +
                    /* JsonParserGenerator.kt:295 */
          59  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:265 */
          60  +
                }
          61  +
                /* JsonParserGenerator.kt:723 */
          62  +
            }
          63  +
            /* JsonParserGenerator.kt:732 */
          64  +
            other => {
          65  +
                return Err(
          66  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
          67  +
                        "expected object key or end object, found: {other:?}"
          68  +
                    )),
          69  +
                )
          70  +
            } /* JsonParserGenerator.kt:722 */
          71  +
        }
          72  +
        /* JsonParserGenerator.kt:721 */
          73  +
    }
          74  +
    /* JsonParserGenerator.kt:255 */
          75  +
    if tokens.next().is_some() {
          76  +
        /* JsonParserGenerator.kt:256 */
          77  +
        return Err(
          78  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          79  +
                "found more JSON tokens after completing parsing",
          80  +
            ),
          81  +
        );
          82  +
        /* JsonParserGenerator.kt:255 */
          83  +
    }
          84  +
    /* JsonParserGenerator.kt:168 */
          85  +
    Ok(builder)
          86  +
    /* JsonParserGenerator.kt:151 */
          87  +
}