Server Test

Server Test

rev. 7254d43655ed63111c94f599437f2b0d3f55446e

Files changed:

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

Renamed from tmp-codegen-diff/codegen-server-test/rest_json_extras/rust-server-codegen/src/protocol_serde/shape_http_query_params_only_operation.rs

@@ -1,1 +103,101 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:412 */
    3      5   
pub async fn de_http_query_params_only_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::HttpQueryParamsOnlyOperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
   17     22   
        let mut input = crate::input::http_query_params_only_operation_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:1235 */
   22     30   
        let query_string = uri.query().unwrap_or("");
   23     31   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
   24         -
        let mut query_params: ::std::collections::HashMap<
   25         -
            ::std::string::String,
   26         -
            ::std::string::String,
   27         -
        > = ::std::collections::HashMap::new();
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          33  +
        let mut query_params: ::std::collections::HashMap::<::std::string::String, ::std::string::String> =
          34  +
            /* ServerHttpBoundProtocolGenerator.kt:1252 */::std::collections::HashMap::new()
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */;
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:1267 */
   28     37   
        for (k, v) in pairs {
          38  +
            /* ServerHttpBoundProtocolGenerator.kt:1353 */
   29     39   
            query_params
   30     40   
                .entry(String::from(k))
   31     41   
                .or_insert_with(|| String::from(v));
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:1267 */
   32     43   
        }
   33         -
        input = input.set_query_map(Some(query_params));
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:1388 */
          45  +
        input = input.set_query_map(
          46  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
          47  +
            Some(
          48  +
                /* ServerHttpBoundProtocolGenerator.kt:1390 */
          49  +
                query_params, /* ServerHttpBoundProtocolGenerator.kt:1389 */
          50  +
            ), /* ServerHttpBoundProtocolGenerator.kt:1388 */
          51  +
        );
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
   34     53   
        input.build()
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
   35     55   
    })
          56  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
   36     57   
}
   37     58   
          59  +
/* RustType.kt:534 */
   38     60   
#[allow(clippy::unnecessary_wraps)]
          61  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
   39     62   
pub fn ser_http_query_params_only_operation_http_response(
   40     63   
    #[allow(unused_variables)] output: crate::output::HttpQueryParamsOnlyOperationOutput,
   41     64   
) -> std::result::Result<
   42     65   
    ::aws_smithy_http_server::response::Response,
   43     66   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   44     67   
> {
          68  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
   45     69   
    Ok({
          70  +
        /* RustType.kt:534 */
   46     71   
        #[allow(unused_mut)]
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
   47     73   
        let mut builder = ::http_1x::Response::builder();
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
   48     75   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     76   
            builder,
   50     77   
            ::http_1x::header::CONTENT_TYPE,
   51     78   
            "application/json",
   52     79   
        );
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
   53     81   
        let http_status: u16 = 200;
   54     82   
        builder = builder.status(http_status);
   55         -
        let payload = "";
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          84  +
        let payload =
          85  +
            /* HttpBoundProtocolPayloadGenerator.kt:238 */""
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */;
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:713 */
   56     88   
        let content_length = payload.len();
   57     89   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     90   
            builder,
   59     91   
            ::http_1x::header::CONTENT_LENGTH,
   60     92   
            content_length,
   61     93   
        );
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:617 */
   62     95   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
   63     97   
        builder.body(body)?
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
   64     99   
    })
   65         -
}
   66         -
   67         -
#[allow(clippy::unnecessary_wraps)]
   68         -
pub fn ser_http_query_params_only_operation_http_error(
   69         -
    error: &crate::error::HttpQueryParamsOnlyOperationError,
   70         -
) -> std::result::Result<
   71         -
    ::aws_smithy_http_server::response::Response,
   72         -
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   73         -
> {
   74         -
    Ok({
   75         -
        match error {
   76         -
            crate::error::HttpQueryParamsOnlyOperationError::ExtraError(output) => {
   77         -
                let payload =
   78         -
                    crate::protocol_serde::shape_extra_error::ser_extra_error_error(output)?;
   79         -
                #[allow(unused_mut)]
   80         -
                let mut builder = ::http_1x::Response::builder();
   81         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82         -
                    builder,
   83         -
                    ::http_1x::header::CONTENT_TYPE,
   84         -
                    "application/json",
   85         -
                );
   86         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87         -
                    builder,
   88         -
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   89         -
                    "ExtraError",
   90         -
                );
   91         -
                let content_length = payload.len();
   92         -
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   93         -
                    builder,
   94         -
                    ::http_1x::header::CONTENT_LENGTH,
   95         -
                    content_length,
   96         -
                );
   97         -
                builder
   98         -
                    .status(500)
   99         -
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  100         -
            }
  101         -
        }
  102         -
    })
         100  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
  103    101   
}

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

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

tmp-codegen-diff/codegen-server-test/rest_json/rust-server-codegen/src/protocol_serde/shape_input_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/rust-server-codegen/src/protocol_serde/shape_input_stream_with_initial_request.rs

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

tmp-codegen-diff/codegen-server-test/rest_json/rust-server-codegen/src/protocol_serde/shape_input_stream_with_initial_request_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_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_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/rust-server-codegen/src/protocol_serde/shape_output_stream.rs

@@ -0,1 +0,165 @@
           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_output_stream_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::OutputStreamInput,
           9  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
          22  +
        let mut input = crate::input::output_stream_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
          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:887 */
          30  +
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
          32  +
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
          34  +
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
          36  +
}
          37  +
          38  +
/* RustType.kt:534 */
          39  +
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
          41  +
pub fn ser_output_stream_http_response(
          42  +
    #[allow(unused_variables)] output: crate::output::OutputStreamOutput,
          43  +
) -> std::result::Result<
          44  +
    ::aws_smithy_http_server::response::Response,
          45  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          46  +
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
          48  +
    Ok({
          49  +
        /* RustType.kt:534 */
          50  +
        #[allow(unused_mut)]
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
          52  +
        let mut builder = ::http_1x::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
          54  +
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
          55  +
            builder,
          56  +
            ::http_1x::header::CONTENT_TYPE,
          57  +
            "application/vnd.amazon.eventstream",
          58  +
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
          60  +
        let http_status: u16 = 200;
          61  +
        builder = builder.status(http_status);
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:589 */
          63  +
        let body = ::aws_smithy_http_server::body::boxed(::http_body_util::StreamBody::new(
          64  +
            /* ServerHttpBoundProtocolGenerator.kt:145 */
          65  +
            {
          66  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          67  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          68  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          69  +
                output
          70  +
                    .stream
          71  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          72  +
            }, /* ServerHttpBoundProtocolGenerator.kt:589 */
          73  +
        ));
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
          75  +
        builder.body(body)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
          77  +
    })
          78  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
          79  +
}
          80  +
          81  +
/* RustType.kt:534 */
          82  +
#[allow(clippy::unnecessary_wraps)]
          83  +
/* ServerHttpBoundProtocolGenerator.kt:475 */
          84  +
pub fn ser_output_stream_http_error(
          85  +
    error: &crate::error::OutputStreamError,
          86  +
) -> std::result::Result<
          87  +
    ::aws_smithy_http_server::response::Response,
          88  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          89  +
> {
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:480 */
          91  +
    Ok({
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:496 */
          93  +
        match error {
          94  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
          95  +
            crate::error::OutputStreamError::ServiceUnavailableError(output) => {
          96  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
          97  +
                let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
          98  +
                /* RustType.kt:534 */
          99  +
                #[allow(unused_mut)]
         100  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         101  +
                let mut builder = ::http_1x::Response::builder();
         102  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         103  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         104  +
                    builder,
         105  +
                    ::http_1x::header::CONTENT_TYPE,
         106  +
                    "application/vnd.amazon.eventstream",
         107  +
                );
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         109  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         110  +
                    builder,
         111  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
         112  +
                    "ServiceUnavailableError",
         113  +
                );
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         115  +
                let content_length = payload.len();
         116  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         117  +
                    builder,
         118  +
                    ::http_1x::header::CONTENT_LENGTH,
         119  +
                    content_length,
         120  +
                );
         121  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         122  +
                builder
         123  +
                    .status(500)
         124  +
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         126  +
            }
         127  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
         128  +
            crate::error::OutputStreamError::ErrorEvent(output) => {
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
         130  +
                let payload =
         131  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         132  +
                /* RustType.kt:534 */
         133  +
                #[allow(unused_mut)]
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         135  +
                let mut builder = ::http_1x::Response::builder();
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         137  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         138  +
                    builder,
         139  +
                    ::http_1x::header::CONTENT_TYPE,
         140  +
                    "application/vnd.amazon.eventstream",
         141  +
                );
         142  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         143  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         144  +
                    builder,
         145  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
         146  +
                    "ErrorEvent",
         147  +
                );
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         149  +
                let content_length = payload.len();
         150  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         151  +
                    builder,
         152  +
                    ::http_1x::header::CONTENT_LENGTH,
         153  +
                    content_length,
         154  +
                );
         155  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         156  +
                builder
         157  +
                    .status(400)
         158  +
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         160  +
            } /* ServerHttpBoundProtocolGenerator.kt:496 */
         161  +
        }
         162  +
        /* ServerHttpBoundProtocolGenerator.kt:480 */
         163  +
    })
         164  +
    /* ServerHttpBoundProtocolGenerator.kt:475 */
         165  +
}

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

@@ -0,1 +0,169 @@
           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_output_stream_with_initial_response_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::OutputStreamWithInitialResponseInput,
           9  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          10  +
>
          11  +
where
          12  +
    B: ::aws_smithy_http_server::body::HttpBody + Send,
          13  +
    B::Data: Send,
          14  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          15  +
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
          16  +
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:428 */
          18  +
    Ok({
          19  +
        /* RustType.kt:534 */
          20  +
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:773 */
          22  +
        let mut input = crate::input::output_stream_with_initial_response_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:778 */
          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:887 */
          30  +
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:910 */
          32  +
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:428 */
          34  +
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:412 */
          36  +
}
          37  +
          38  +
/* RustType.kt:534 */
          39  +
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:449 */
          41  +
pub fn ser_output_stream_with_initial_response_http_response(
          42  +
    #[allow(unused_variables)] output: crate::output::OutputStreamWithInitialResponseOutput,
          43  +
) -> std::result::Result<
          44  +
    ::aws_smithy_http_server::response::Response,
          45  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          46  +
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:461 */
          48  +
    Ok({
          49  +
        /* RustType.kt:534 */
          50  +
        #[allow(unused_mut)]
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:551 */
          52  +
        let mut builder = ::http_1x::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:679 */
          54  +
        builder = crate::protocol_serde::shape_output_stream_with_initial_response::ser_output_stream_with_initial_response_headers(&output, builder)?;
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:647 */
          56  +
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http_1x::header::CONTENT_TYPE,
          59  +
            "application/vnd.amazon.eventstream",
          60  +
        );
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:732 */
          62  +
        let http_status: u16 = 200;
          63  +
        builder = builder.status(http_status);
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:589 */
          65  +
        let body = ::aws_smithy_http_server::body::boxed(::http_body_util::StreamBody::new(
          66  +
            /* ServerHttpBoundProtocolGenerator.kt:145 */
          67  +
            {
          68  +
                let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
          69  +
                let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
          70  +
                let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
          71  +
                output
          72  +
                    .stream
          73  +
                    .into_body_stream(marshaller, error_marshaller, signer)
          74  +
            }, /* ServerHttpBoundProtocolGenerator.kt:589 */
          75  +
        ));
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:625 */
          77  +
        builder.body(body)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:461 */
          79  +
    })
          80  +
    /* ServerHttpBoundProtocolGenerator.kt:449 */
          81  +
}
          82  +
          83  +
/* RustType.kt:534 */
          84  +
#[allow(clippy::unnecessary_wraps)]
          85  +
/* ServerHttpBoundProtocolGenerator.kt:475 */
          86  +
pub fn ser_output_stream_with_initial_response_http_error(
          87  +
    error: &crate::error::OutputStreamWithInitialResponseError,
          88  +
) -> std::result::Result<
          89  +
    ::aws_smithy_http_server::response::Response,
          90  +
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          91  +
> {
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:480 */
          93  +
    Ok({
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:496 */
          95  +
        match error {
          96  +
            /* ServerHttpBoundProtocolGenerator.kt:504 */
          97  +
            crate::error::OutputStreamWithInitialResponseError::ErrorEvent(output) => {
          98  +
                /* ServerHttpBoundProtocolGenerator.kt:505 */
          99  +
                let payload =
         100  +
                    crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
         101  +
                /* RustType.kt:534 */
         102  +
                #[allow(unused_mut)]
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:515 */
         104  +
                let mut builder = ::http_1x::Response::builder();
         105  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         106  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         107  +
                    builder,
         108  +
                    ::http_1x::header::CONTENT_TYPE,
         109  +
                    "application/vnd.amazon.eventstream",
         110  +
                );
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:647 */
         112  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         113  +
                    builder,
         114  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
         115  +
                    "ErrorEvent",
         116  +
                );
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:713 */
         118  +
                let content_length = payload.len();
         119  +
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
         120  +
                    builder,
         121  +
                    ::http_1x::header::CONTENT_LENGTH,
         122  +
                    content_length,
         123  +
                );
         124  +
                /* ServerHttpBoundProtocolGenerator.kt:532 */
         125  +
                builder
         126  +
                    .status(400)
         127  +
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
         129  +
            } /* ServerHttpBoundProtocolGenerator.kt:496 */
         130  +
        }
         131  +
        /* ServerHttpBoundProtocolGenerator.kt:480 */
         132  +
    })
         133  +
    /* ServerHttpBoundProtocolGenerator.kt:475 */
         134  +
}
         135  +
         136  +
/* HttpBindingGenerator.kt:565 */
         137  +
pub fn ser_output_stream_with_initial_response_headers(
         138  +
    input: &crate::output::OutputStreamWithInitialResponseOutput,
         139  +
    mut builder: ::http_1x::response::Builder,
         140  +
) -> std::result::Result<
         141  +
    ::http_1x::response::Builder,
         142  +
    ::aws_smithy_types::error::operation::BuildError,
         143  +
> {
         144  +
    /* SerializerUtil.kt:42 */
         145  +
    {
         146  +
        /* HttpBindingGenerator.kt:727 */
         147  +
        let formatted_1 = &input.initial_response_member.as_str();
         148  +
        /* HttpBindingGenerator.kt:728 */
         149  +
        if !formatted_1.is_empty() {
         150  +
            /* HttpBindingGenerator.kt:729 */
         151  +
            let header_value = formatted_1;
         152  +
            let header_value: ::http_1x::HeaderValue = header_value.parse().map_err(|err| {
         153  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         154  +
                    "initial_response_member",
         155  +
                    format!(
         156  +
                        "`{}` cannot be used as a header value: {}",
         157  +
                        &header_value, err
         158  +
                    ),
         159  +
                )
         160  +
            })?;
         161  +
            builder = builder.header("initial-response-member", header_value);
         162  +
            /* HttpBindingGenerator.kt:728 */
         163  +
        }
         164  +
        /* SerializerUtil.kt:42 */
         165  +
    }
         166  +
    /* HttpBindingGenerator.kt:578 */
         167  +
    Ok(builder)
         168  +
    /* HttpBindingGenerator.kt:565 */
         169  +
}

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

@@ -0,1 +0,128 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:180 */
           3  +
pub(crate) fn de_payload_structure_payload(
           4  +
    _value: &[u8],
           5  +
) -> ::std::result::Result<
           6  +
    crate::model::PayloadStructure,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* JsonParserGenerator.kt:192 */
          10  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          11  +
        crate::protocol_serde::or_empty_doc(_value),
          12  +
    )
          13  +
    .peekable();
          14  +
    let tokens = &mut tokens_owned;
          15  +
    /* JsonParserGenerator.kt:199 */
          16  +
    let result =
          17  +
    /* JsonParserGenerator.kt:581 */crate::protocol_serde::shape_payload_structure::de_payload_structure(tokens, _value)?
          18  +
    /* JsonParserGenerator.kt:201 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          19  +
    /* JsonParserGenerator.kt:255 */
          20  +
    if tokens.next().is_some() {
          21  +
        /* JsonParserGenerator.kt:256 */
          22  +
        return Err(
          23  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          24  +
                "found more JSON tokens after completing parsing",
          25  +
            ),
          26  +
        );
          27  +
        /* JsonParserGenerator.kt:255 */
          28  +
    }
          29  +
    /* JsonParserGenerator.kt:203 */
          30  +
    result
          31  +
    /* JsonParserGenerator.kt:180 */
          32  +
}
          33  +
          34  +
/* JsonSerializerGenerator.kt:360 */
          35  +
pub fn ser_payload_structure(
          36  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          37  +
    input: &crate::model::PayloadStructure,
          38  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          39  +
    /* JsonSerializerGenerator.kt:384 */
          40  +
    if let Some(var_1) = &input.structure_member {
          41  +
        /* JsonSerializerGenerator.kt:425 */
          42  +
        object.key("structureMember").string(var_1.as_str());
          43  +
        /* JsonSerializerGenerator.kt:384 */
          44  +
    }
          45  +
    /* JsonSerializerGenerator.kt:374 */
          46  +
    Ok(())
          47  +
    /* JsonSerializerGenerator.kt:360 */
          48  +
}
          49  +
          50  +
/* JsonParserGenerator.kt:553 */
          51  +
pub(crate) fn de_payload_structure<'a, I>(
          52  +
    tokens: &mut ::std::iter::Peekable<I>,
          53  +
    _value: &'a [u8],
          54  +
) -> ::std::result::Result<
          55  +
    Option<crate::model::PayloadStructure>,
          56  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          57  +
>
          58  +
where
          59  +
    I: Iterator<
          60  +
        Item = Result<
          61  +
            ::aws_smithy_json::deserialize::Token<'a>,
          62  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          63  +
        >,
          64  +
    >,
          65  +
{
          66  +
    /* JsonParserGenerator.kt:749 */
          67  +
    match tokens.next().transpose()? {
          68  +
        /* JsonParserGenerator.kt:750 */
          69  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          70  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          71  +
            /* RustType.kt:534 */
          72  +
            #[allow(unused_mut)]
          73  +
            /* JsonParserGenerator.kt:563 */
          74  +
            let mut builder = crate::model::payload_structure::Builder::default();
          75  +
            /* JsonParserGenerator.kt:721 */
          76  +
            loop {
          77  +
                /* JsonParserGenerator.kt:722 */
          78  +
                match tokens.next().transpose()? {
          79  +
                    /* JsonParserGenerator.kt:723 */
          80  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          81  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          82  +
                        /* JsonParserGenerator.kt:265 */
          83  +
                        match key.to_unescaped()?.as_ref() {
          84  +
                            /* JsonParserGenerator.kt:267 */
          85  +
                            "structureMember" => {
          86  +
                                /* JsonParserGenerator.kt:277 */
          87  +
                                builder = builder.set_structure_member(
          88  +
                                    /* JsonParserGenerator.kt:361 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          89  +
                                        /* JsonParserGenerator.kt:346 */s.to_unescaped().map(|u|
          90  +
                                            /* JsonParserGenerator.kt:355 */u.into_owned()
          91  +
                                        /* JsonParserGenerator.kt:346 */)
          92  +
                                    /* JsonParserGenerator.kt:361 */).transpose()?
          93  +
                                /* JsonParserGenerator.kt:277 */);
          94  +
                                /* JsonParserGenerator.kt:267 */
          95  +
                            }
          96  +
                            /* JsonParserGenerator.kt:295 */
          97  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:265 */
          98  +
                        }
          99  +
                        /* JsonParserGenerator.kt:723 */
         100  +
                    }
         101  +
                    /* JsonParserGenerator.kt:732 */
         102  +
                    other => {
         103  +
                        return Err(
         104  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         105  +
                                format!("expected object key or end object, found: {other:?}"),
         106  +
                            ),
         107  +
                        )
         108  +
                    } /* JsonParserGenerator.kt:722 */
         109  +
                }
         110  +
                /* JsonParserGenerator.kt:721 */
         111  +
            }
         112  +
            /* JsonParserGenerator.kt:577 */
         113  +
            Ok(Some(builder.build()))
         114  +
            /* JsonParserGenerator.kt:750 */
         115  +
        }
         116  +
        /* JsonParserGenerator.kt:759 */
         117  +
        _ => {
         118  +
            /* JsonParserGenerator.kt:760 */
         119  +
            Err(
         120  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         121  +
                    "expected start object or null",
         122  +
                ),
         123  +
            )
         124  +
            /* JsonParserGenerator.kt:759 */
         125  +
        } /* JsonParserGenerator.kt:749 */
         126  +
    }
         127  +
    /* JsonParserGenerator.kt:553 */
         128  +
}

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

@@ -0,1 +0,168 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:180 */
           3  +
pub(crate) fn de_payload_union_payload(
           4  +
    _value: &[u8],
           5  +
) -> ::std::result::Result<
           6  +
    crate::model::PayloadUnion,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* JsonParserGenerator.kt:192 */
          10  +
    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(
          11  +
        crate::protocol_serde::or_empty_doc(_value),
          12  +
    )
          13  +
    .peekable();
          14  +
    let tokens = &mut tokens_owned;
          15  +
    /* JsonParserGenerator.kt:199 */
          16  +
    let result =
          17  +
    /* JsonParserGenerator.kt:697 */crate::protocol_serde::shape_payload_union::de_payload_union(tokens, _value)?
          18  +
    /* JsonParserGenerator.kt:201 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("expected payload member value"));
          19  +
    /* JsonParserGenerator.kt:255 */
          20  +
    if tokens.next().is_some() {
          21  +
        /* JsonParserGenerator.kt:256 */
          22  +
        return Err(
          23  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          24  +
                "found more JSON tokens after completing parsing",
          25  +
            ),
          26  +
        );
          27  +
        /* JsonParserGenerator.kt:255 */
          28  +
    }
          29  +
    /* JsonParserGenerator.kt:203 */
          30  +
    result
          31  +
    /* JsonParserGenerator.kt:180 */
          32  +
}
          33  +
          34  +
/* JsonSerializerGenerator.kt:559 */
          35  +
pub fn ser_payload_union(
          36  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          37  +
    input: &crate::model::PayloadUnion,
          38  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          39  +
    /* JsonSerializerGenerator.kt:568 */
          40  +
    match input {
          41  +
        /* JsonSerializerGenerator.kt:576 */
          42  +
        crate::model::PayloadUnion::UnionMember(inner) => {
          43  +
            /* SerializerUtil.kt:42 */
          44  +
            {
          45  +
                /* JsonSerializerGenerator.kt:425 */
          46  +
                object.key("unionMember").string(inner.as_str());
          47  +
                /* SerializerUtil.kt:42 */
          48  +
            }
          49  +
            /* JsonSerializerGenerator.kt:576 */
          50  +
        }
          51  +
        /* JsonSerializerGenerator.kt:568 */
          52  +
    }
          53  +
    /* JsonSerializerGenerator.kt:588 */
          54  +
    Ok(())
          55  +
    /* JsonSerializerGenerator.kt:559 */
          56  +
}
          57  +
          58  +
/* JsonParserGenerator.kt:588 */
          59  +
pub(crate) fn de_payload_union<'a, I>(
          60  +
    tokens: &mut ::std::iter::Peekable<I>,
          61  +
    _value: &'a [u8],
          62  +
) -> ::std::result::Result<
          63  +
    Option<crate::model::PayloadUnion>,
          64  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          65  +
>
          66  +
where
          67  +
    I: Iterator<
          68  +
        Item = Result<
          69  +
            ::aws_smithy_json::deserialize::Token<'a>,
          70  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          71  +
        >,
          72  +
    >,
          73  +
{
          74  +
    /* JsonParserGenerator.kt:602 */
          75  +
    let mut variant = None;
          76  +
    /* JsonParserGenerator.kt:604 */
          77  +
    match tokens.next().transpose()? {
          78  +
        /* JsonParserGenerator.kt:605 */
          79  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          80  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          81  +
            /* JsonParserGenerator.kt:721 */
          82  +
            loop {
          83  +
                /* JsonParserGenerator.kt:722 */
          84  +
                match tokens.next().transpose()? {
          85  +
                    /* JsonParserGenerator.kt:723 */
          86  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          87  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          88  +
                        /* JsonParserGenerator.kt:613 */
          89  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          90  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          91  +
                        )) = tokens.peek()
          92  +
                        {
          93  +
                            let _ = tokens.next().expect("peek returned a token")?;
          94  +
                            continue;
          95  +
                        }
          96  +
                        /* JsonParserGenerator.kt:622 */
          97  +
                        let key = key.to_unescaped()?;
          98  +
                        if key == "__type" {
          99  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
         100  +
                            continue;
         101  +
                        }
         102  +
                        if variant.is_some() {
         103  +
                            return Err(
         104  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         105  +
                                    "encountered mixed variants in union",
         106  +
                                ),
         107  +
                            );
         108  +
                        }
         109  +
                        /* JsonParserGenerator.kt:635 */
         110  +
                        variant = match key.as_ref() {
         111  +
                            /* JsonParserGenerator.kt:638 */
         112  +
                            "unionMember" => {
         113  +
                                /* JsonParserGenerator.kt:648 */
         114  +
                                Some(crate::model::PayloadUnion::UnionMember(
         115  +
                                    /* JsonParserGenerator.kt:361 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
         116  +
                                        /* JsonParserGenerator.kt:346 */s.to_unescaped().map(|u|
         117  +
                                            /* JsonParserGenerator.kt:355 */u.into_owned()
         118  +
                                        /* JsonParserGenerator.kt:346 */)
         119  +
                                    /* JsonParserGenerator.kt:361 */).transpose()?
         120  +
                                    /* JsonParserGenerator.kt:707 */.ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'unionMember' cannot be null"))?
         121  +
                                /* JsonParserGenerator.kt:648 */))
         122  +
                                /* JsonParserGenerator.kt:638 */
         123  +
                            }
         124  +
                            /* JsonParserGenerator.kt:671 */
         125  +
                            variant => {
         126  +
                                return Err(
         127  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         128  +
                                        format!("unexpected union variant: {variant}"),
         129  +
                                    ),
         130  +
                                )
         131  +
                            } /* JsonParserGenerator.kt:635 */
         132  +
                        };
         133  +
                        /* JsonParserGenerator.kt:723 */
         134  +
                    }
         135  +
                    /* JsonParserGenerator.kt:732 */
         136  +
                    other => {
         137  +
                        return Err(
         138  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         139  +
                                format!("expected object key or end object, found: {other:?}"),
         140  +
                            ),
         141  +
                        )
         142  +
                    } /* JsonParserGenerator.kt:722 */
         143  +
                }
         144  +
                /* JsonParserGenerator.kt:721 */
         145  +
            }
         146  +
            /* JsonParserGenerator.kt:605 */
         147  +
        }
         148  +
        /* JsonParserGenerator.kt:679 */
         149  +
        _ => {
         150  +
            return Err(
         151  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         152  +
                    "expected start object or null",
         153  +
                ),
         154  +
            )
         155  +
        } /* JsonParserGenerator.kt:604 */
         156  +
    }
         157  +
    /* JsonParserGenerator.kt:686 */
         158  +
    if variant.is_none() {
         159  +
        return Err(
         160  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         161  +
                "Union did not contain a valid variant.",
         162  +
            ),
         163  +
        );
         164  +
    }
         165  +
    /* JsonParserGenerator.kt:694 */
         166  +
    Ok(variant)
         167  +
    /* JsonParserGenerator.kt:588 */
         168  +
}