Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +101,146 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_timestamp_query_http_date_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampQueryHttpDateInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_timestamp_query_http_date_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:1073 */
   22     30   
        let query_string = uri.query().unwrap_or("");
   23     31   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   24     33   
        let mut timestamp_seen = false;
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   25     35   
        for (k, v) in pairs {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   26     37   
            if !timestamp_seen && k == "timestamp" {
   27     38   
                input = input.set_timestamp(
   28     39   
                    crate::protocol_serde::shape_malformed_timestamp_query_http_date_input::de_timestamp(&v)?
   29     40   
                );
   30     41   
                timestamp_seen = true;
   31     42   
            }
          43  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   32     44   
        }
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     46   
        input.build()?
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     48   
    })
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     50   
}
   36     51   
          52  +
/* RustType.kt:516 */
   37     53   
#[allow(clippy::unnecessary_wraps)]
          54  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     55   
pub fn ser_malformed_timestamp_query_http_date_http_response(
   39     56   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampQueryHttpDateOutput,
   40     57   
) -> std::result::Result<
   41     58   
    ::aws_smithy_http_server::response::Response,
   42     59   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     60   
> {
          61  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     62   
    Ok({
          63  +
        /* RustType.kt:516 */
   45     64   
        #[allow(unused_mut)]
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     66   
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     69   
            builder,
   49     70   
            ::http::header::CONTENT_TYPE,
   50     71   
            "application/json",
   51     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     74   
        let http_status: u16 = 200;
   53     75   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          77  +
        let payload =
          78  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     81   
        let content_length = payload.len();
   56     82   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     83   
            builder,
   58     84   
            ::http::header::CONTENT_LENGTH,
   59     85   
            content_length,
   60     86   
        );
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     88   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     90   
        builder.body(body)?
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     92   
    })
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     94   
}
   65     95   
          96  +
/* RustType.kt:516 */
   66     97   
#[allow(clippy::unnecessary_wraps)]
          98  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     99   
pub fn ser_malformed_timestamp_query_http_date_http_error(
   68    100   
    error: &crate::error::MalformedTimestampQueryHttpDateError,
   69    101   
) -> std::result::Result<
   70    102   
    ::aws_smithy_http_server::response::Response,
   71    103   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    104   
> {
         105  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    106   
    Ok({
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    108   
        match error {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    110   
            crate::error::MalformedTimestampQueryHttpDateError::ValidationException(output) => {
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    112   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         113  +
                /* RustType.kt:516 */
   77    114   
                #[allow(unused_mut)]
         115  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    116   
                let mut builder = ::http::Response::builder();
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    118   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    119   
                    builder,
   81    120   
                    ::http::header::CONTENT_TYPE,
   82    121   
                    "application/json",
   83    122   
                );
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    124   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    125   
                    builder,
   86    126   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    127   
                    "ValidationException",
   88    128   
                );
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    130   
                let content_length = payload.len();
   90    131   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    132   
                    builder,
   92    133   
                    ::http::header::CONTENT_LENGTH,
   93    134   
                    content_length,
   94    135   
                );
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    137   
                builder
   96    138   
                    .status(400)
   97    139   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         141  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    142   
        }
   99         -
        }
         143  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    144   
    })
         145  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    146   
}

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

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

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

@@ -1,1 +109,156 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_union_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedUnionInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_union_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_union::de_malformed_union(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   33     45   
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   34     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   35     49   
}
   36     50   
          51  +
/* RustType.kt:516 */
   37     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   38     54   
pub fn ser_malformed_union_http_response(
   39     55   
    #[allow(unused_variables)] output: crate::output::MalformedUnionOutput,
   40     56   
) -> std::result::Result<
   41     57   
    ::aws_smithy_http_server::response::Response,
   42     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   44     61   
    Ok({
          62  +
        /* RustType.kt:516 */
   45     63   
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   46     65   
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   47     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     68   
            builder,
   49     69   
            ::http::header::CONTENT_TYPE,
   50     70   
            "application/json",
   51     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   52     73   
        let http_status: u16 = 200;
   53     74   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     80   
        let content_length = payload.len();
   56     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     82   
            builder,
   58     83   
            ::http::header::CONTENT_LENGTH,
   59     84   
            content_length,
   60     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     93   
}
   65     94   
          95  +
/* JsonParserGenerator.kt:148 */
   66     96   
pub(crate) fn de_malformed_union(
   67     97   
    value: &[u8],
   68     98   
    mut builder: crate::input::malformed_union_input::Builder,
   69     99   
) -> ::std::result::Result<
   70    100   
    crate::input::malformed_union_input::Builder,
   71    101   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   72    102   
> {
         103  +
    /* JsonParserGenerator.kt:153 */
   73    104   
    let mut tokens_owned =
   74    105   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   75    106   
            .peekable();
   76    107   
    let tokens = &mut tokens_owned;
   77    108   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         109  +
    /* JsonParserGenerator.kt:684 */
   78    110   
    loop {
         111  +
        /* JsonParserGenerator.kt:685 */
   79    112   
        match tokens.next().transpose()? {
         113  +
            /* JsonParserGenerator.kt:686 */
   80    114   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   81    115   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                /* JsonParserGenerator.kt:260 */
   82    117   
                match key.to_unescaped()?.as_ref() {
         118  +
                    /* JsonParserGenerator.kt:262 */
   83    119   
                    "union" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
   84    121   
                        builder = builder.set_union(
   85         -
                            crate::protocol_serde::shape_simple_union::de_simple_union(tokens)?,
   86         -
                        );
         122  +
                            /* JsonParserGenerator.kt:660 */crate::protocol_serde::shape_simple_union::de_simple_union(tokens)?
         123  +
                        /* JsonParserGenerator.kt:272 */);
         124  +
                        /* JsonParserGenerator.kt:262 */
   87    125   
                    }
   88         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         126  +
                    /* JsonParserGenerator.kt:290 */
         127  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   89    128   
                }
         129  +
                /* JsonParserGenerator.kt:686 */
   90    130   
            }
         131  +
            /* JsonParserGenerator.kt:695 */
   91    132   
            other => {
   92    133   
                return Err(
   93    134   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   94    135   
                        "expected object key or end object, found: {:?}",
   95    136   
                        other
   96    137   
                    )),
   97    138   
                )
         139  +
            } /* JsonParserGenerator.kt:685 */
   98    140   
        }
         141  +
        /* JsonParserGenerator.kt:684 */
   99    142   
    }
  100         -
    }
         143  +
    /* JsonParserGenerator.kt:250 */
  101    144   
    if tokens.next().is_some() {
         145  +
        /* JsonParserGenerator.kt:251 */
  102    146   
        return Err(
  103    147   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  104    148   
                "found more JSON tokens after completing parsing",
  105    149   
            ),
  106    150   
        );
         151  +
        /* JsonParserGenerator.kt:250 */
  107    152   
    }
         153  +
    /* JsonParserGenerator.kt:163 */
  108    154   
    Ok(builder)
         155  +
    /* JsonParserGenerator.kt:148 */
  109    156   
}

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

@@ -1,1 +87,121 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_media_type_header_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MediaTypeHeaderInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::media_type_header_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:794 */
   22     30   
        if let Some(value) =
   23     31   
            crate::protocol_serde::shape_media_type_header_input::de_json_header(&headers)?
   24     32   
        {
   25     33   
            input = input.set_json(Some(value))
   26     34   
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   27     36   
        input.build()
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   28     38   
    })
          39  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   29     40   
}
   30     41   
          42  +
/* RustType.kt:516 */
   31     43   
#[allow(clippy::unnecessary_wraps)]
          44  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   32     45   
pub fn ser_media_type_header_http_response(
   33     46   
    #[allow(unused_variables)] output: crate::output::MediaTypeHeaderOutput,
   34     47   
) -> std::result::Result<
   35     48   
    ::aws_smithy_http_server::response::Response,
   36     49   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   37     50   
> {
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   38     52   
    Ok({
          53  +
        /* RustType.kt:516 */
   39     54   
        #[allow(unused_mut)]
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   40     56   
        let mut builder = ::http::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   41     58   
        builder = crate::protocol_serde::shape_media_type_header::ser_media_type_header_headers(
   42     59   
            &output, builder,
   43     60   
        )?;
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   44     62   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     63   
            builder,
   46     64   
            ::http::header::CONTENT_TYPE,
   47     65   
            "application/json",
   48     66   
        );
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   49     68   
        let http_status: u16 = 200;
   50     69   
        builder = builder.status(http_status);
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   51     71   
        let payload =
   52         -
            crate::protocol_serde::shape_media_type_header_output::ser_media_type_header_output_output_output(&output)?
   53         -
        ;
          72  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_media_type_header_output::ser_media_type_header_output_output_output(&output)?
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   54     75   
        let content_length = payload.len();
   55     76   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   56     77   
            builder,
   57     78   
            ::http::header::CONTENT_LENGTH,
   58     79   
            content_length,
   59     80   
        );
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   60     82   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   61     84   
        builder.body(body)?
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   62     86   
    })
          87  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   63     88   
}
   64     89   
          90  +
/* HttpBindingGenerator.kt:542 */
   65     91   
pub fn ser_media_type_header_headers(
   66     92   
    input: &crate::output::MediaTypeHeaderOutput,
   67     93   
    mut builder: ::http::response::Builder,
   68     94   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
   69     95   
{
          96  +
    /* HttpBindingGenerator.kt:592 */
   70     97   
    if let ::std::option::Option::Some(inner_1) = &input.json {
          98  +
        /* HttpBindingGenerator.kt:704 */
   71     99   
        let formatted_2 = ::aws_smithy_types::base64::encode(inner_1);
         100  +
        /* HttpBindingGenerator.kt:705 */
   72    101   
        if !formatted_2.is_empty() {
         102  +
            /* HttpBindingGenerator.kt:706 */
   73    103   
            let header_value = formatted_2;
   74    104   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   75    105   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
   76    106   
                    "json",
   77    107   
                    format!(
   78    108   
                        "`{}` cannot be used as a header value: {}",
   79    109   
                        &header_value, err
   80    110   
                    ),
   81    111   
                )
   82    112   
            })?;
   83    113   
            builder = builder.header("X-Json", header_value);
         114  +
            /* HttpBindingGenerator.kt:705 */
   84    115   
        }
         116  +
        /* HttpBindingGenerator.kt:592 */
   85    117   
    }
         118  +
    /* HttpBindingGenerator.kt:555 */
   86    119   
    Ok(builder)
         120  +
    /* HttpBindingGenerator.kt:542 */
   87    121   
}

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

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

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

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

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

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

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

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

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

@@ -1,1 +49,74 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
    2      3   
pub(crate) fn de_nested_string_list<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<::std::vec::Vec<::std::vec::Vec<::std::string::String>>>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          22  +
            /* JsonParserGenerator.kt:407 */
   19     23   
            let mut items = Vec::new();
          24  +
            /* JsonParserGenerator.kt:408 */
   20     25   
            loop {
          26  +
                /* JsonParserGenerator.kt:409 */
   21     27   
                match tokens.peek() {
          28  +
                    /* JsonParserGenerator.kt:410 */
   22     29   
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          30  +
                        /* JsonParserGenerator.kt:411 */
   23     31   
                        tokens.next().transpose().unwrap();
   24     32   
                        break;
          33  +
                        /* JsonParserGenerator.kt:410 */
   25     34   
                    }
          35  +
                    /* JsonParserGenerator.kt:413 */
   26     36   
                    _ => {
          37  +
                        /* JsonParserGenerator.kt:419 */
   27     38   
                        let value =
   28         -
                            crate::protocol_serde::shape_string_list::de_string_list(tokens)?;
          39  +
                            /* JsonParserGenerator.kt:451 */crate::protocol_serde::shape_string_list::de_string_list(tokens)?
          40  +
                        /* JsonParserGenerator.kt:419 */;
          41  +
                        /* JsonParserGenerator.kt:422 */
   29     42   
                        if let Some(value) = value {
   30     43   
                            items.push(value);
   31         -
                        } else {
          44  +
                        }
          45  +
                        /* JsonParserGenerator.kt:430 */
          46  +
                        else {
   32     47   
                            return Err(
   33     48   
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   34     49   
                                    "dense list cannot contain null values",
   35     50   
                                ),
   36     51   
                            );
   37     52   
                        }
          53  +
                        /* JsonParserGenerator.kt:413 */
          54  +
                    } /* JsonParserGenerator.kt:409 */
   38     55   
                }
          56  +
                /* JsonParserGenerator.kt:408 */
   39     57   
            }
   40         -
            }
          58  +
            /* JsonParserGenerator.kt:446 */
   41     59   
            Ok(Some(items))
          60  +
            /* JsonParserGenerator.kt:713 */
   42     61   
        }
   43         -
        _ => Err(
          62  +
        /* JsonParserGenerator.kt:722 */
          63  +
        _ => {
          64  +
            /* JsonParserGenerator.kt:723 */
          65  +
            Err(
   44     66   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   45     67   
                    "expected start array or null",
   46     68   
                ),
   47         -
        ),
          69  +
            )
          70  +
            /* JsonParserGenerator.kt:722 */
          71  +
        } /* JsonParserGenerator.kt:712 */
   48     72   
    }
          73  +
    /* JsonParserGenerator.kt:398 */
   49     74   
}

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

@@ -1,1 +54,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_no_input_and_no_output_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NoInputAndNoOutputInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::no_input_and_no_output_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:811 */
   22     30   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   23     32   
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   24     34   
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   25     36   
}
   26     37   
          38  +
/* RustType.kt:516 */
   27     39   
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   28     41   
pub fn ser_no_input_and_no_output_http_response(
   29     42   
    #[allow(unused_variables)] output: crate::output::NoInputAndNoOutputOutput,
   30     43   
) -> std::result::Result<
   31     44   
    ::aws_smithy_http_server::response::Response,
   32     45   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   33     46   
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   34     48   
    Ok({
          49  +
        /* RustType.kt:516 */
   35     50   
        #[allow(unused_mut)]
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   36     52   
        let mut builder = ::http::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   37     54   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   38     55   
            builder,
   39     56   
            ::http::header::CONTENT_TYPE,
   40     57   
            "application/json",
   41     58   
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   42     60   
        let http_status: u16 = 200;
   43     61   
        builder = builder.status(http_status);
   44         -
        let payload = "";
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          63  +
        let payload =
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   45     67   
        let content_length = payload.len();
   46     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   47     69   
            builder,
   48     70   
            ::http::header::CONTENT_LENGTH,
   49     71   
            content_length,
   50     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   51     74   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   52     76   
        builder.body(body)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   53     78   
    })
          79  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   54     80   
}

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

@@ -1,1 +56,80 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_no_input_and_output_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NoInputAndOutputInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::no_input_and_output_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:811 */
   22     30   
        ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(&headers, None)?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   23     32   
        input.build()
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   24     34   
    })
          35  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   25     36   
}
   26     37   
          38  +
/* RustType.kt:516 */
   27     39   
#[allow(clippy::unnecessary_wraps)]
          40  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   28     41   
pub fn ser_no_input_and_output_http_response(
   29     42   
    #[allow(unused_variables)] output: crate::output::NoInputAndOutputOutput,
   30     43   
) -> std::result::Result<
   31     44   
    ::aws_smithy_http_server::response::Response,
   32     45   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   33     46   
> {
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   34     48   
    Ok({
          49  +
        /* RustType.kt:516 */
   35     50   
        #[allow(unused_mut)]
          51  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   36     52   
        let mut builder = ::http::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   37     54   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   38     55   
            builder,
   39     56   
            ::http::header::CONTENT_TYPE,
   40     57   
            "application/json",
   41     58   
        );
          59  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   42     60   
        let http_status: u16 = 200;
   43     61   
        builder = builder.status(http_status);
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   44     63   
        let payload =
   45         -
            crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
   46         -
        ;
          64  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   47     67   
        let content_length = payload.len();
   48     68   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     69   
            builder,
   50     70   
            ::http::header::CONTENT_LENGTH,
   51     71   
            content_length,
   52     72   
        );
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   53     74   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   54     76   
        builder.body(body)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   55     78   
    })
          79  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   56     80   
}

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

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

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

@@ -1,1 +129,179 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_null_and_empty_headers_client_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NullAndEmptyHeadersClientInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::null_and_empty_headers_client_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:794 */
   22     30   
        if let Some(value) =
   23     31   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_a_header(&headers)?
   24     32   
        {
   25     33   
            input = input.set_a(Some(value))
   26     34   
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   27     36   
        if let Some(value) =
   28     37   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_b_header(&headers)?
   29     38   
        {
   30     39   
            input = input.set_b(Some(value))
   31     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   32     42   
        if let Some(value) =
   33     43   
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_c_header(&headers)?
   34     44   
        {
   35     45   
            input = input.set_c(Some(value))
   36     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   37     48   
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   38     50   
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   39     52   
}
   40     53   
          54  +
/* RustType.kt:516 */
   41     55   
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   42     57   
pub fn ser_null_and_empty_headers_client_http_response(
   43     58   
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersClientOutput,
   44     59   
) -> std::result::Result<
   45     60   
    ::aws_smithy_http_server::response::Response,
   46     61   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   47     62   
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   48     64   
    Ok({
          65  +
        /* RustType.kt:516 */
   49     66   
        #[allow(unused_mut)]
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   50     68   
        let mut builder = ::http::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   51     70   
        builder = crate::protocol_serde::shape_null_and_empty_headers_client::ser_null_and_empty_headers_client_headers(&output, builder)?;
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   52     72   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   53     73   
            builder,
   54     74   
            ::http::header::CONTENT_TYPE,
   55     75   
            "application/json",
   56     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   57     78   
        let http_status: u16 = 200;
   58     79   
        builder = builder.status(http_status);
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   59     81   
        let payload =
   60         -
            crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output_output(&output)?
   61         -
        ;
          82  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output_output(&output)?
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   62     85   
        let content_length = payload.len();
   63     86   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   64     87   
            builder,
   65     88   
            ::http::header::CONTENT_LENGTH,
   66     89   
            content_length,
   67     90   
        );
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   68     92   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   69     94   
        builder.body(body)?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   70     96   
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   71     98   
}
   72     99   
         100  +
/* HttpBindingGenerator.kt:542 */
   73    101   
pub fn ser_null_and_empty_headers_client_headers(
   74    102   
    input: &crate::output::NullAndEmptyHeadersClientOutput,
   75    103   
    mut builder: ::http::response::Builder,
   76    104   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
   77    105   
{
         106  +
    /* HttpBindingGenerator.kt:592 */
   78    107   
    if let ::std::option::Option::Some(inner_1) = &input.a {
         108  +
        /* HttpBindingGenerator.kt:704 */
   79    109   
        let formatted_2 = inner_1.as_str();
         110  +
        /* HttpBindingGenerator.kt:705 */
   80    111   
        if !formatted_2.is_empty() {
         112  +
            /* HttpBindingGenerator.kt:706 */
   81    113   
            let header_value = formatted_2;
   82    114   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   83    115   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
   84    116   
                    "a",
   85    117   
                    format!(
   86    118   
                        "`{}` cannot be used as a header value: {}",
   87    119   
                        &header_value, err
   88    120   
                    ),
   89    121   
                )
   90    122   
            })?;
   91    123   
            builder = builder.header("X-A", header_value);
         124  +
            /* HttpBindingGenerator.kt:705 */
   92    125   
        }
         126  +
        /* HttpBindingGenerator.kt:592 */
   93    127   
    }
         128  +
    /* HttpBindingGenerator.kt:592 */
   94    129   
    if let ::std::option::Option::Some(inner_3) = &input.b {
         130  +
        /* HttpBindingGenerator.kt:704 */
   95    131   
        let formatted_4 = inner_3.as_str();
         132  +
        /* HttpBindingGenerator.kt:705 */
   96    133   
        if !formatted_4.is_empty() {
         134  +
            /* HttpBindingGenerator.kt:706 */
   97    135   
            let header_value = formatted_4;
   98    136   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   99    137   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  100    138   
                    "b",
  101    139   
                    format!(
  102    140   
                        "`{}` cannot be used as a header value: {}",
  103    141   
                        &header_value, err
  104    142   
                    ),
  105    143   
                )
  106    144   
            })?;
  107    145   
            builder = builder.header("X-B", header_value);
         146  +
            /* HttpBindingGenerator.kt:705 */
  108    147   
        }
         148  +
        /* HttpBindingGenerator.kt:592 */
  109    149   
    }
         150  +
    /* HttpBindingGenerator.kt:592 */
  110    151   
    if let ::std::option::Option::Some(inner_5) = &input.c {
         152  +
        /* HttpBindingGenerator.kt:646 */
  111    153   
        for inner_6 in inner_5 {
         154  +
            /* HttpBindingGenerator.kt:704 */
  112    155   
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
         156  +
            /* HttpBindingGenerator.kt:705 */
  113    157   
            if !formatted_7.is_empty() {
         158  +
                /* HttpBindingGenerator.kt:706 */
  114    159   
                let header_value = formatted_7;
  115    160   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  116    161   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  117    162   
                        "c",
  118    163   
                        format!(
  119    164   
                            "`{}` cannot be used as a header value: {}",
  120    165   
                            &header_value, err
  121    166   
                        ),
  122    167   
                    )
  123    168   
                })?;
  124    169   
                builder = builder.header("X-C", header_value);
         170  +
                /* HttpBindingGenerator.kt:705 */
  125    171   
            }
         172  +
            /* HttpBindingGenerator.kt:646 */
  126    173   
        }
         174  +
        /* HttpBindingGenerator.kt:592 */
  127    175   
    }
         176  +
    /* HttpBindingGenerator.kt:555 */
  128    177   
    Ok(builder)
         178  +
    /* HttpBindingGenerator.kt:542 */
  129    179   
}

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

@@ -1,1 +31,44 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_a_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::std::string::String>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:160 */
    8     10   
    let headers = header_map.get_all("X-A");
          11  +
    /* HttpBindingGenerator.kt:375 */
    9     12   
    ::aws_smithy_http::header::one_or_none(headers)
          13  +
    /* HttpBindingGenerator.kt:153 */
   10     14   
}
   11     15   
          16  +
/* HttpBindingGenerator.kt:153 */
   12     17   
pub(crate) fn de_b_header(
   13     18   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   14     19   
) -> ::std::result::Result<
   15     20   
    ::std::option::Option<::std::string::String>,
   16     21   
    ::aws_smithy_http::header::ParseError,
   17     22   
> {
          23  +
    /* HttpBindingGenerator.kt:160 */
   18     24   
    let headers = header_map.get_all("X-B");
          25  +
    /* HttpBindingGenerator.kt:375 */
   19     26   
    ::aws_smithy_http::header::one_or_none(headers)
          27  +
    /* HttpBindingGenerator.kt:153 */
   20     28   
}
   21     29   
          30  +
/* HttpBindingGenerator.kt:153 */
   22     31   
pub(crate) fn de_c_header(
   23     32   
    header_map: &::aws_smithy_runtime_api::http::Headers,
   24     33   
) -> ::std::result::Result<
   25     34   
    ::std::option::Option<::std::vec::Vec<::std::string::String>>,
   26     35   
    ::aws_smithy_http::header::ParseError,
   27     36   
> {
          37  +
    /* HttpBindingGenerator.kt:160 */
   28     38   
    let headers = header_map.get_all("X-C");
          39  +
    /* HttpBindingGenerator.kt:409 */
   29     40   
    let var_1: Vec<::std::string::String> = ::aws_smithy_http::header::read_many_from_str(headers)?;
          41  +
    /* HttpBindingGenerator.kt:430 */
   30     42   
    Ok(if !var_1.is_empty() { Some(var_1) } else { None })
          43  +
    /* HttpBindingGenerator.kt:153 */
   31     44   
}

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

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

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

@@ -1,1 +129,179 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_null_and_empty_headers_server_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::NullAndEmptyHeadersServerInput,
    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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::null_and_empty_headers_server_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   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:794 */
   22     30   
        if let Some(value) =
   23     31   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_a_header(&headers)?
   24     32   
        {
   25     33   
            input = input.set_a(Some(value))
   26     34   
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   27     36   
        if let Some(value) =
   28     37   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_b_header(&headers)?
   29     38   
        {
   30     39   
            input = input.set_b(Some(value))
   31     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   32     42   
        if let Some(value) =
   33     43   
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_c_header(&headers)?
   34     44   
        {
   35     45   
            input = input.set_c(Some(value))
   36     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   37     48   
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   38     50   
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   39     52   
}
   40     53   
          54  +
/* RustType.kt:516 */
   41     55   
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   42     57   
pub fn ser_null_and_empty_headers_server_http_response(
   43     58   
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersServerOutput,
   44     59   
) -> std::result::Result<
   45     60   
    ::aws_smithy_http_server::response::Response,
   46     61   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   47     62   
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   48     64   
    Ok({
          65  +
        /* RustType.kt:516 */
   49     66   
        #[allow(unused_mut)]
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   50     68   
        let mut builder = ::http::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:629 */
   51     70   
        builder = crate::protocol_serde::shape_null_and_empty_headers_server::ser_null_and_empty_headers_server_headers(&output, builder)?;
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   52     72   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   53     73   
            builder,
   54     74   
            ::http::header::CONTENT_TYPE,
   55     75   
            "application/json",
   56     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   57     78   
        let http_status: u16 = 200;
   58     79   
        builder = builder.status(http_status);
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
   59     81   
        let payload =
   60         -
            crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output_output(&output)?
   61         -
        ;
          82  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output_output(&output)?
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   62     85   
        let content_length = payload.len();
   63     86   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   64     87   
            builder,
   65     88   
            ::http::header::CONTENT_LENGTH,
   66     89   
            content_length,
   67     90   
        );
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   68     92   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   69     94   
        builder.body(body)?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   70     96   
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   71     98   
}
   72     99   
         100  +
/* HttpBindingGenerator.kt:542 */
   73    101   
pub fn ser_null_and_empty_headers_server_headers(
   74    102   
    input: &crate::output::NullAndEmptyHeadersServerOutput,
   75    103   
    mut builder: ::http::response::Builder,
   76    104   
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
   77    105   
{
         106  +
    /* HttpBindingGenerator.kt:592 */
   78    107   
    if let ::std::option::Option::Some(inner_1) = &input.a {
         108  +
        /* HttpBindingGenerator.kt:704 */
   79    109   
        let formatted_2 = inner_1.as_str();
         110  +
        /* HttpBindingGenerator.kt:705 */
   80    111   
        if !formatted_2.is_empty() {
         112  +
            /* HttpBindingGenerator.kt:706 */
   81    113   
            let header_value = formatted_2;
   82    114   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   83    115   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
   84    116   
                    "a",
   85    117   
                    format!(
   86    118   
                        "`{}` cannot be used as a header value: {}",
   87    119   
                        &header_value, err
   88    120   
                    ),
   89    121   
                )
   90    122   
            })?;
   91    123   
            builder = builder.header("X-A", header_value);
         124  +
            /* HttpBindingGenerator.kt:705 */
   92    125   
        }
         126  +
        /* HttpBindingGenerator.kt:592 */
   93    127   
    }
         128  +
    /* HttpBindingGenerator.kt:592 */
   94    129   
    if let ::std::option::Option::Some(inner_3) = &input.b {
         130  +
        /* HttpBindingGenerator.kt:704 */
   95    131   
        let formatted_4 = inner_3.as_str();
         132  +
        /* HttpBindingGenerator.kt:705 */
   96    133   
        if !formatted_4.is_empty() {
         134  +
            /* HttpBindingGenerator.kt:706 */
   97    135   
            let header_value = formatted_4;
   98    136   
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
   99    137   
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
  100    138   
                    "b",
  101    139   
                    format!(
  102    140   
                        "`{}` cannot be used as a header value: {}",
  103    141   
                        &header_value, err
  104    142   
                    ),
  105    143   
                )
  106    144   
            })?;
  107    145   
            builder = builder.header("X-B", header_value);
         146  +
            /* HttpBindingGenerator.kt:705 */
  108    147   
        }
         148  +
        /* HttpBindingGenerator.kt:592 */
  109    149   
    }
         150  +
    /* HttpBindingGenerator.kt:592 */
  110    151   
    if let ::std::option::Option::Some(inner_5) = &input.c {
         152  +
        /* HttpBindingGenerator.kt:646 */
  111    153   
        for inner_6 in inner_5 {
         154  +
            /* HttpBindingGenerator.kt:704 */
  112    155   
            let formatted_7 = ::aws_smithy_http::header::quote_header_value(inner_6.as_str());
         156  +
            /* HttpBindingGenerator.kt:705 */
  113    157   
            if !formatted_7.is_empty() {
         158  +
                /* HttpBindingGenerator.kt:706 */
  114    159   
                let header_value = formatted_7;
  115    160   
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
  116    161   
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
  117    162   
                        "c",
  118    163   
                        format!(
  119    164   
                            "`{}` cannot be used as a header value: {}",
  120    165   
                            &header_value, err
  121    166   
                        ),
  122    167   
                    )
  123    168   
                })?;
  124    169   
                builder = builder.header("X-C", header_value);
         170  +
                /* HttpBindingGenerator.kt:705 */
  125    171   
            }
         172  +
            /* HttpBindingGenerator.kt:646 */
  126    173   
        }
         174  +
        /* HttpBindingGenerator.kt:592 */
  127    175   
    }
         176  +
    /* HttpBindingGenerator.kt:555 */
  128    177   
    Ok(builder)
         178  +
    /* HttpBindingGenerator.kt:542 */
  129    179   
}