Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405

Files changed:

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

@@ -1,1 +120,175 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_request_body_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedRequestBodyInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_request_body_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_request_body::de_malformed_request_body(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   33     48   
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   34     50   
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   35     52   
}
   36     53   
          54  +
/* RustType.kt:534 */
   37     55   
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   38     57   
pub fn ser_malformed_request_body_http_response(
   39     58   
    #[allow(unused_variables)] output: crate::output::MalformedRequestBodyOutput,
   40     59   
) -> std::result::Result<
   41     60   
    ::aws_smithy_http_server::response::Response,
   42     61   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   43     62   
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   44     64   
    Ok({
          65  +
        /* RustType.kt:534 */
   45     66   
        #[allow(unused_mut)]
   46         -
        let mut builder = ::http::Response::builder();
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          68  +
        let mut builder = ::http_1x::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   47     70   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   48     71   
            builder,
   49         -
            ::http::header::CONTENT_TYPE,
          72  +
            ::http_1x::header::CONTENT_TYPE,
   50     73   
            "application/json",
   51     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   52     76   
        let http_status: u16 = 200;
   53     77   
        builder = builder.status(http_status);
   54         -
        let payload = "";
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          79  +
        let payload =
          80  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   55     83   
        let content_length = payload.len();
   56     84   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     85   
            builder,
   58         -
            ::http::header::CONTENT_LENGTH,
          86  +
            ::http_1x::header::CONTENT_LENGTH,
   59     87   
            content_length,
   60     88   
        );
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   61     90   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   62     92   
        builder.body(body)?
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   63     94   
    })
          95  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   64     96   
}
   65     97   
          98  +
/* JsonParserGenerator.kt:148 */
   66     99   
pub(crate) fn de_malformed_request_body(
   67    100   
    value: &[u8],
   68    101   
    mut builder: crate::input::malformed_request_body_input::Builder,
   69    102   
) -> ::std::result::Result<
   70    103   
    crate::input::malformed_request_body_input::Builder,
   71    104   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   72    105   
> {
         106  +
    /* JsonParserGenerator.kt:153 */
   73    107   
    let mut tokens_owned =
   74    108   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   75    109   
            .peekable();
   76    110   
    let tokens = &mut tokens_owned;
   77    111   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         112  +
    /* JsonParserGenerator.kt:684 */
   78    113   
    loop {
         114  +
        /* JsonParserGenerator.kt:685 */
   79    115   
        match tokens.next().transpose()? {
         116  +
            /* JsonParserGenerator.kt:686 */
   80    117   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   81    118   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                /* JsonParserGenerator.kt:260 */
   82    120   
                match key.to_unescaped()?.as_ref() {
         121  +
                    /* JsonParserGenerator.kt:262 */
   83    122   
                    "float" => {
         123  +
                        /* JsonParserGenerator.kt:272 */
   84    124   
                        builder = builder.set_float(
         125  +
                            /* JsonParserGenerator.kt:361 */
   85    126   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
   86    127   
                                tokens.next(),
   87    128   
                            )?
   88         -
                            .map(|v| v.to_f32_lossy()),
         129  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
   89    130   
                        );
         131  +
                        /* JsonParserGenerator.kt:262 */
   90    132   
                    }
         133  +
                    /* JsonParserGenerator.kt:262 */
   91    134   
                    "int" => {
         135  +
                        /* JsonParserGenerator.kt:272 */
   92    136   
                        builder = builder.set_int(
         137  +
                            /* JsonParserGenerator.kt:365 */
   93    138   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
   94    139   
                                tokens.next(),
   95    140   
                            )?
   96    141   
                            .map(i32::try_from)
   97         -
                            .transpose()?,
         142  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
   98    143   
                        );
         144  +
                        /* JsonParserGenerator.kt:262 */
   99    145   
                    }
  100         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         146  +
                    /* JsonParserGenerator.kt:290 */
         147  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  101    148   
                }
         149  +
                /* JsonParserGenerator.kt:686 */
  102    150   
            }
         151  +
            /* JsonParserGenerator.kt:695 */
  103    152   
            other => {
  104    153   
                return Err(
  105    154   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  106    155   
                        "expected object key or end object, found: {other:?}"
  107    156   
                    )),
  108    157   
                )
  109         -
            }
         158  +
            } /* JsonParserGenerator.kt:685 */
  110    159   
        }
         160  +
        /* JsonParserGenerator.kt:684 */
  111    161   
    }
         162  +
    /* JsonParserGenerator.kt:250 */
  112    163   
    if tokens.next().is_some() {
         164  +
        /* JsonParserGenerator.kt:251 */
  113    165   
        return Err(
  114    166   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  115    167   
                "found more JSON tokens after completing parsing",
  116    168   
            ),
  117    169   
        );
         170  +
        /* JsonParserGenerator.kt:250 */
  118    171   
    }
         172  +
    /* JsonParserGenerator.kt:163 */
  119    173   
    Ok(builder)
         174  +
    /* JsonParserGenerator.kt:148 */
  120    175   
}

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

@@ -1,1 +186,261 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_short_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedShortInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_short_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_short::de_malformed_short(
   29     42   
                bytes.as_ref(),
   30     43   
                input,
   31     44   
            )?;
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   32     46   
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   33     48   
        if let Some(value) =
   34     49   
            crate::protocol_serde::shape_malformed_short_input::de_short_in_header_header(&headers)?
   35     50   
        {
   36     51   
            input = input.set_short_in_header(Some(value))
   37     52   
        }
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:1134 */
   38     54   
        let input_string = uri.path();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   39     56   
        let (input_string, (_, m1)) =
   40     57   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     58   
                ::nom::sequence::preceded(
   42     59   
                    ::nom::bytes::complete::tag("/"),
   43     60   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   44     61   
                        "MalformedShort",
   45     62   
                    ),
   46     63   
                ),
   47     64   
                ::nom::sequence::preceded(
   48     65   
                    ::nom::bytes::complete::tag("/"),
   49     66   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   50     67   
                        ::nom::bytes::complete::take_until("/"),
   51     68   
                        ::nom::combinator::rest,
   52     69   
                    )),
   53     70   
                ),
   54     71   
            ))(input_string)?;
   55     72   
        debug_assert_eq!("", input_string);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   56     74   
        input = input.set_short_in_path(
   57     75   
            crate::protocol_serde::shape_malformed_short_input::de_short_in_path(m1)?,
   58     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1221 */
   59     78   
        let query_string = uri.query().unwrap_or("");
   60     79   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
   61     81   
        let mut short_in_query_seen = false;
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
   62     83   
        for (k, v) in pairs {
          84  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
   63     85   
            if !short_in_query_seen && k == "shortInQuery" {
   64     86   
                input = input.set_short_in_query(
   65     87   
                    crate::protocol_serde::shape_malformed_short_input::de_short_in_query(&v)?,
   66     88   
                );
   67     89   
                short_in_query_seen = true;
   68     90   
            }
          91  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
   69     92   
        }
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   70     94   
        input.build()?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   71     96   
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   72     98   
}
   73     99   
         100  +
/* RustType.kt:534 */
   74    101   
#[allow(clippy::unnecessary_wraps)]
         102  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   75    103   
pub fn ser_malformed_short_http_response(
   76    104   
    #[allow(unused_variables)] output: crate::output::MalformedShortOutput,
   77    105   
) -> std::result::Result<
   78    106   
    ::aws_smithy_http_server::response::Response,
   79    107   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    108   
> {
         109  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   81    110   
    Ok({
         111  +
        /* RustType.kt:534 */
   82    112   
        #[allow(unused_mut)]
   83         -
        let mut builder = ::http::Response::builder();
         113  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         114  +
        let mut builder = ::http_1x::Response::builder();
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   84    116   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    117   
            builder,
   86         -
            ::http::header::CONTENT_TYPE,
         118  +
            ::http_1x::header::CONTENT_TYPE,
   87    119   
            "application/json",
   88    120   
        );
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   89    122   
        let http_status: u16 = 200;
   90    123   
        builder = builder.status(http_status);
   91         -
        let payload = "";
         124  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         125  +
        let payload =
         126  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         128  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   92    129   
        let content_length = payload.len();
   93    130   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    131   
            builder,
   95         -
            ::http::header::CONTENT_LENGTH,
         132  +
            ::http_1x::header::CONTENT_LENGTH,
   96    133   
            content_length,
   97    134   
        );
         135  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   98    136   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         137  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   99    138   
        builder.body(body)?
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
  100    140   
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
  101    142   
}
  102    143   
         144  +
/* RustType.kt:534 */
  103    145   
#[allow(clippy::unnecessary_wraps)]
         146  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
  104    147   
pub fn ser_malformed_short_http_error(
  105    148   
    error: &crate::error::MalformedShortError,
  106    149   
) -> std::result::Result<
  107    150   
    ::aws_smithy_http_server::response::Response,
  108    151   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  109    152   
> {
         153  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
  110    154   
    Ok({
         155  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
  111    156   
        match error {
         157  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
  112    158   
            crate::error::MalformedShortError::ValidationException(output) => {
         159  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
  113    160   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         161  +
                /* RustType.kt:534 */
  114    162   
                #[allow(unused_mut)]
  115         -
                let mut builder = ::http::Response::builder();
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         164  +
                let mut builder = ::http_1x::Response::builder();
         165  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  116    166   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    167   
                    builder,
  118         -
                    ::http::header::CONTENT_TYPE,
         168  +
                    ::http_1x::header::CONTENT_TYPE,
  119    169   
                    "application/json",
  120    170   
                );
         171  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
  121    172   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  122    173   
                    builder,
  123         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         174  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
  124    175   
                    "ValidationException",
  125    176   
                );
         177  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
  126    178   
                let content_length = payload.len();
  127    179   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  128    180   
                    builder,
  129         -
                    ::http::header::CONTENT_LENGTH,
         181  +
                    ::http_1x::header::CONTENT_LENGTH,
  130    182   
                    content_length,
  131    183   
                );
         184  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  132    185   
                builder
  133    186   
                    .status(400)
  134    187   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  135         -
            }
         188  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         189  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  136    190   
        }
         191  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  137    192   
    })
         193  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  138    194   
}
  139    195   
         196  +
/* JsonParserGenerator.kt:148 */
  140    197   
pub(crate) fn de_malformed_short(
  141    198   
    value: &[u8],
  142    199   
    mut builder: crate::input::malformed_short_input::Builder,
  143    200   
) -> ::std::result::Result<
  144    201   
    crate::input::malformed_short_input::Builder,
  145    202   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  146    203   
> {
         204  +
    /* JsonParserGenerator.kt:153 */
  147    205   
    let mut tokens_owned =
  148    206   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  149    207   
            .peekable();
  150    208   
    let tokens = &mut tokens_owned;
  151    209   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         210  +
    /* JsonParserGenerator.kt:684 */
  152    211   
    loop {
         212  +
        /* JsonParserGenerator.kt:685 */
  153    213   
        match tokens.next().transpose()? {
         214  +
            /* JsonParserGenerator.kt:686 */
  154    215   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  155    216   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         217  +
                /* JsonParserGenerator.kt:260 */
  156    218   
                match key.to_unescaped()?.as_ref() {
         219  +
                    /* JsonParserGenerator.kt:262 */
  157    220   
                    "shortInBody" => {
         221  +
                        /* JsonParserGenerator.kt:272 */
  158    222   
                        builder = builder.set_short_in_body(
         223  +
                            /* JsonParserGenerator.kt:365 */
  159    224   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  160    225   
                                tokens.next(),
  161    226   
                            )?
  162    227   
                            .map(i16::try_from)
  163         -
                            .transpose()?,
         228  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  164    229   
                        );
         230  +
                        /* JsonParserGenerator.kt:262 */
  165    231   
                    }
  166         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         232  +
                    /* JsonParserGenerator.kt:290 */
         233  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  167    234   
                }
         235  +
                /* JsonParserGenerator.kt:686 */
  168    236   
            }
         237  +
            /* JsonParserGenerator.kt:695 */
  169    238   
            other => {
  170    239   
                return Err(
  171    240   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  172    241   
                        "expected object key or end object, found: {other:?}"
  173    242   
                    )),
  174    243   
                )
  175         -
            }
         244  +
            } /* JsonParserGenerator.kt:685 */
  176    245   
        }
         246  +
        /* JsonParserGenerator.kt:684 */
  177    247   
    }
         248  +
    /* JsonParserGenerator.kt:250 */
  178    249   
    if tokens.next().is_some() {
         250  +
        /* JsonParserGenerator.kt:251 */
  179    251   
        return Err(
  180    252   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  181    253   
                "found more JSON tokens after completing parsing",
  182    254   
            ),
  183    255   
        );
         256  +
        /* JsonParserGenerator.kt:250 */
  184    257   
    }
         258  +
    /* JsonParserGenerator.kt:163 */
  185    259   
    Ok(builder)
         260  +
    /* JsonParserGenerator.kt:148 */
  186    261   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_short_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i16>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:166 */
    5      7   
    let headers = header_map.get_all("shortInHeader");
           8  +
    /* HttpBindingGenerator.kt:427 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i16>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:491 */
    7     11   
    if var_1.len() > 1 {
    8     12   
        Err(::aws_smithy_http::header::ParseError::new(format!(
    9     13   
            "expected one item but found {}",
   10     14   
            var_1.len()
   11     15   
        )))
   12     16   
    } else {
   13     17   
        let mut var_1 = var_1;
   14     18   
        Ok(var_1.pop())
   15     19   
    }
          20  +
    /* HttpBindingGenerator.kt:159 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   18     24   
pub fn de_short_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i16,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
   28     38   
pub fn de_short_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i16>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1515 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   36     49   
}

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

@@ -1,1 +58,84 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_string_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedStringInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_string_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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:856 */
   22     30   
        if let Some(value) =
   23     31   
            crate::protocol_serde::shape_malformed_string_input::de_blob_header(&headers)?
   24     32   
        {
   25     33   
            input = input.set_blob(Some(value))
   26     34   
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   27     36   
        input.build()
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   28     38   
    })
          39  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   29     40   
}
   30     41   
          42  +
/* RustType.kt:534 */
   31     43   
#[allow(clippy::unnecessary_wraps)]
          44  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   32     45   
pub fn ser_malformed_string_http_response(
   33     46   
    #[allow(unused_variables)] output: crate::output::MalformedStringOutput,
   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:457 */
   38     52   
    Ok({
          53  +
        /* RustType.kt:534 */
   39     54   
        #[allow(unused_mut)]
   40         -
        let mut builder = ::http::Response::builder();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          56  +
        let mut builder = ::http_1x::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   41     58   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   42     59   
            builder,
   43         -
            ::http::header::CONTENT_TYPE,
          60  +
            ::http_1x::header::CONTENT_TYPE,
   44     61   
            "application/json",
   45     62   
        );
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   46     64   
        let http_status: u16 = 200;
   47     65   
        builder = builder.status(http_status);
   48         -
        let payload = "";
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          67  +
        let payload =
          68  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   49     71   
        let content_length = payload.len();
   50     72   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   51     73   
            builder,
   52         -
            ::http::header::CONTENT_LENGTH,
          74  +
            ::http_1x::header::CONTENT_LENGTH,
   53     75   
            content_length,
   54     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   55     78   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   56     80   
        builder.body(body)?
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   57     82   
    })
          83  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   58     84   
}

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

@@ -1,1 +34,41 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_blob_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:166 */
    8     10   
    let headers = header_map.get_all("amz-media-typed-header");
          11  +
    /* HttpBindingGenerator.kt:432 */
    9     12   
    let var_1: Vec<::std::string::String> = ::aws_smithy_http::header::read_many_from_str(headers)?;
          13  +
    /* HttpBindingGenerator.kt:437 */
   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:448 */
   24     29   
    let var_1 = var_1?;
          30  +
    /* HttpBindingGenerator.kt:491 */
   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:159 */
   34     41   
}

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

@@ -1,1 +147,214 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_body_date_time_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampBodyDateTimeInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_body_date_time_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_timestamp_body_date_time::de_malformed_timestamp_body_date_time(bytes.as_ref(), input)?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   29     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   30     45   
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   31     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   32     49   
}
   33     50   
          51  +
/* RustType.kt:534 */
   34     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   35     54   
pub fn ser_malformed_timestamp_body_date_time_http_response(
   36     55   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampBodyDateTimeOutput,
   37     56   
) -> std::result::Result<
   38     57   
    ::aws_smithy_http_server::response::Response,
   39     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   41     61   
    Ok({
          62  +
        /* RustType.kt:534 */
   42     63   
        #[allow(unused_mut)]
   43         -
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http_1x::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   44     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     68   
            builder,
   46         -
            ::http::header::CONTENT_TYPE,
          69  +
            ::http_1x::header::CONTENT_TYPE,
   47     70   
            "application/json",
   48     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   49     73   
        let http_status: u16 = 200;
   50     74   
        builder = builder.status(http_status);
   51         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   52     80   
        let content_length = payload.len();
   53     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     82   
            builder,
   55         -
            ::http::header::CONTENT_LENGTH,
          83  +
            ::http_1x::header::CONTENT_LENGTH,
   56     84   
            content_length,
   57     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   58     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   59     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   60     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   61     93   
}
   62     94   
          95  +
/* RustType.kt:534 */
   63     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   64     98   
pub fn ser_malformed_timestamp_body_date_time_http_error(
   65     99   
    error: &crate::error::MalformedTimestampBodyDateTimeError,
   66    100   
) -> std::result::Result<
   67    101   
    ::aws_smithy_http_server::response::Response,
   68    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   69    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   70    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   71    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   72    109   
            crate::error::MalformedTimestampBodyDateTimeError::ValidationException(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   73    111   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:534 */
   74    113   
                #[allow(unused_mut)]
   75         -
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         115  +
                let mut builder = ::http_1x::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   76    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    118   
                    builder,
   78         -
                    ::http::header::CONTENT_TYPE,
         119  +
                    ::http_1x::header::CONTENT_TYPE,
   79    120   
                    "application/json",
   80    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   81    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    124   
                    builder,
   83         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         125  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   84    126   
                    "ValidationException",
   85    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   86    129   
                let content_length = payload.len();
   87    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    131   
                    builder,
   89         -
                    ::http::header::CONTENT_LENGTH,
         132  +
                    ::http_1x::header::CONTENT_LENGTH,
   90    133   
                    content_length,
   91    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   92    136   
                builder
   93    137   
                    .status(400)
   94    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   95         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   96    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   97    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   98    145   
}
   99    146   
         147  +
/* JsonParserGenerator.kt:148 */
  100    148   
pub(crate) fn de_malformed_timestamp_body_date_time(
  101    149   
    value: &[u8],
  102    150   
    mut builder: crate::input::malformed_timestamp_body_date_time_input::Builder,
  103    151   
) -> ::std::result::Result<
  104    152   
    crate::input::malformed_timestamp_body_date_time_input::Builder,
  105    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  106    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  107    156   
    let mut tokens_owned =
  108    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  109    158   
            .peekable();
  110    159   
    let tokens = &mut tokens_owned;
  111    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  112    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  113    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  114    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  115    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  116    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  117    171   
                    "timestamp" => {
         172  +
                        /* JsonParserGenerator.kt:276 */
  118    173   
                        if let Some(v) =
         174  +
                            /* JsonParserGenerator.kt:384 */
  119    175   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  120         -
                                tokens.next(),
  121         -
                                ::aws_smithy_types::date_time::Format::DateTime,
  122         -
                            )?
         176  +
                                    tokens.next(),
         177  +
                                    ::aws_smithy_types::date_time::Format::DateTime,
         178  +
                                )?
         179  +
                        /* JsonParserGenerator.kt:278 */
  123    180   
                        {
  124    181   
                            builder = builder.set_timestamp(v);
  125    182   
                        }
         183  +
                        /* JsonParserGenerator.kt:262 */
  126    184   
                    }
  127         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         185  +
                    /* JsonParserGenerator.kt:290 */
         186  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  128    187   
                }
         188  +
                /* JsonParserGenerator.kt:686 */
  129    189   
            }
         190  +
            /* JsonParserGenerator.kt:695 */
  130    191   
            other => {
  131    192   
                return Err(
  132    193   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  133    194   
                        "expected object key or end object, found: {other:?}"
  134    195   
                    )),
  135    196   
                )
  136         -
            }
         197  +
            } /* JsonParserGenerator.kt:685 */
  137    198   
        }
         199  +
        /* JsonParserGenerator.kt:684 */
  138    200   
    }
         201  +
    /* JsonParserGenerator.kt:250 */
  139    202   
    if tokens.next().is_some() {
         203  +
        /* JsonParserGenerator.kt:251 */
  140    204   
        return Err(
  141    205   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  142    206   
                "found more JSON tokens after completing parsing",
  143    207   
            ),
  144    208   
        );
         209  +
        /* JsonParserGenerator.kt:250 */
  145    210   
    }
         211  +
    /* JsonParserGenerator.kt:163 */
  146    212   
    Ok(builder)
         213  +
    /* JsonParserGenerator.kt:148 */
  147    214   
}

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

@@ -1,1 +147,214 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_body_default_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampBodyDefaultInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_body_default_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_timestamp_body_default::de_malformed_timestamp_body_default(bytes.as_ref(), input)?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   29     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   30     45   
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   31     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   32     49   
}
   33     50   
          51  +
/* RustType.kt:534 */
   34     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   35     54   
pub fn ser_malformed_timestamp_body_default_http_response(
   36     55   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampBodyDefaultOutput,
   37     56   
) -> std::result::Result<
   38     57   
    ::aws_smithy_http_server::response::Response,
   39     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   41     61   
    Ok({
          62  +
        /* RustType.kt:534 */
   42     63   
        #[allow(unused_mut)]
   43         -
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http_1x::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   44     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     68   
            builder,
   46         -
            ::http::header::CONTENT_TYPE,
          69  +
            ::http_1x::header::CONTENT_TYPE,
   47     70   
            "application/json",
   48     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   49     73   
        let http_status: u16 = 200;
   50     74   
        builder = builder.status(http_status);
   51         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   52     80   
        let content_length = payload.len();
   53     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     82   
            builder,
   55         -
            ::http::header::CONTENT_LENGTH,
          83  +
            ::http_1x::header::CONTENT_LENGTH,
   56     84   
            content_length,
   57     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   58     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   59     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   60     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   61     93   
}
   62     94   
          95  +
/* RustType.kt:534 */
   63     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   64     98   
pub fn ser_malformed_timestamp_body_default_http_error(
   65     99   
    error: &crate::error::MalformedTimestampBodyDefaultError,
   66    100   
) -> std::result::Result<
   67    101   
    ::aws_smithy_http_server::response::Response,
   68    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   69    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   70    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   71    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   72    109   
            crate::error::MalformedTimestampBodyDefaultError::ValidationException(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   73    111   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:534 */
   74    113   
                #[allow(unused_mut)]
   75         -
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         115  +
                let mut builder = ::http_1x::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   76    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    118   
                    builder,
   78         -
                    ::http::header::CONTENT_TYPE,
         119  +
                    ::http_1x::header::CONTENT_TYPE,
   79    120   
                    "application/json",
   80    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   81    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    124   
                    builder,
   83         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         125  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   84    126   
                    "ValidationException",
   85    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   86    129   
                let content_length = payload.len();
   87    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    131   
                    builder,
   89         -
                    ::http::header::CONTENT_LENGTH,
         132  +
                    ::http_1x::header::CONTENT_LENGTH,
   90    133   
                    content_length,
   91    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   92    136   
                builder
   93    137   
                    .status(400)
   94    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   95         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   96    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   97    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   98    145   
}
   99    146   
         147  +
/* JsonParserGenerator.kt:148 */
  100    148   
pub(crate) fn de_malformed_timestamp_body_default(
  101    149   
    value: &[u8],
  102    150   
    mut builder: crate::input::malformed_timestamp_body_default_input::Builder,
  103    151   
) -> ::std::result::Result<
  104    152   
    crate::input::malformed_timestamp_body_default_input::Builder,
  105    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  106    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  107    156   
    let mut tokens_owned =
  108    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  109    158   
            .peekable();
  110    159   
    let tokens = &mut tokens_owned;
  111    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  112    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  113    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  114    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  115    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  116    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  117    171   
                    "timestamp" => {
         172  +
                        /* JsonParserGenerator.kt:276 */
  118    173   
                        if let Some(v) =
         174  +
                            /* JsonParserGenerator.kt:384 */
  119    175   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  120         -
                                tokens.next(),
  121         -
                                ::aws_smithy_types::date_time::Format::EpochSeconds,
  122         -
                            )?
         176  +
                                    tokens.next(),
         177  +
                                    ::aws_smithy_types::date_time::Format::EpochSeconds,
         178  +
                                )?
         179  +
                        /* JsonParserGenerator.kt:278 */
  123    180   
                        {
  124    181   
                            builder = builder.set_timestamp(v);
  125    182   
                        }
         183  +
                        /* JsonParserGenerator.kt:262 */
  126    184   
                    }
  127         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         185  +
                    /* JsonParserGenerator.kt:290 */
         186  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  128    187   
                }
         188  +
                /* JsonParserGenerator.kt:686 */
  129    189   
            }
         190  +
            /* JsonParserGenerator.kt:695 */
  130    191   
            other => {
  131    192   
                return Err(
  132    193   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  133    194   
                        "expected object key or end object, found: {other:?}"
  134    195   
                    )),
  135    196   
                )
  136         -
            }
         197  +
            } /* JsonParserGenerator.kt:685 */
  137    198   
        }
         199  +
        /* JsonParserGenerator.kt:684 */
  138    200   
    }
         201  +
    /* JsonParserGenerator.kt:250 */
  139    202   
    if tokens.next().is_some() {
         203  +
        /* JsonParserGenerator.kt:251 */
  140    204   
        return Err(
  141    205   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  142    206   
                "found more JSON tokens after completing parsing",
  143    207   
            ),
  144    208   
        );
         209  +
        /* JsonParserGenerator.kt:250 */
  145    210   
    }
         211  +
    /* JsonParserGenerator.kt:163 */
  146    212   
    Ok(builder)
         213  +
    /* JsonParserGenerator.kt:148 */
  147    214   
}

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

@@ -1,1 +147,214 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_body_http_date_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampBodyHttpDateInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_body_http_date_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:789 */
          30  +
        let bytes = {
          31  +
            use ::http_body_util::BodyExt;
          32  +
            body.collect().await?.to_bytes()
          33  +
        };
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
   23     35   
        if !bytes.is_empty() {
          36  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
   24     37   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     38   
                &headers,
   26     39   
                Some("application/json"),
   27     40   
            )?;
   28     41   
            input = crate::protocol_serde::shape_malformed_timestamp_body_http_date::de_malformed_timestamp_body_http_date(bytes.as_ref(), input)?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
   29     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   30     45   
        input.build()?
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   31     47   
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   32     49   
}
   33     50   
          51  +
/* RustType.kt:534 */
   34     52   
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   35     54   
pub fn ser_malformed_timestamp_body_http_date_http_response(
   36     55   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampBodyHttpDateOutput,
   37     56   
) -> std::result::Result<
   38     57   
    ::aws_smithy_http_server::response::Response,
   39     58   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     59   
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   41     61   
    Ok({
          62  +
        /* RustType.kt:534 */
   42     63   
        #[allow(unused_mut)]
   43         -
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http_1x::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   44     67   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     68   
            builder,
   46         -
            ::http::header::CONTENT_TYPE,
          69  +
            ::http_1x::header::CONTENT_TYPE,
   47     70   
            "application/json",
   48     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   49     73   
        let http_status: u16 = 200;
   50     74   
        builder = builder.status(http_status);
   51         -
        let payload = "";
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   52     80   
        let content_length = payload.len();
   53     81   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     82   
            builder,
   55         -
            ::http::header::CONTENT_LENGTH,
          83  +
            ::http_1x::header::CONTENT_LENGTH,
   56     84   
            content_length,
   57     85   
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   58     87   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   59     89   
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   60     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   61     93   
}
   62     94   
          95  +
/* RustType.kt:534 */
   63     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   64     98   
pub fn ser_malformed_timestamp_body_http_date_http_error(
   65     99   
    error: &crate::error::MalformedTimestampBodyHttpDateError,
   66    100   
) -> std::result::Result<
   67    101   
    ::aws_smithy_http_server::response::Response,
   68    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   69    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   70    105   
    Ok({
         106  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   71    107   
        match error {
         108  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   72    109   
            crate::error::MalformedTimestampBodyHttpDateError::ValidationException(output) => {
         110  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   73    111   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         112  +
                /* RustType.kt:534 */
   74    113   
                #[allow(unused_mut)]
   75         -
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         115  +
                let mut builder = ::http_1x::Response::builder();
         116  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   76    117   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    118   
                    builder,
   78         -
                    ::http::header::CONTENT_TYPE,
         119  +
                    ::http_1x::header::CONTENT_TYPE,
   79    120   
                    "application/json",
   80    121   
                );
         122  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   81    123   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   82    124   
                    builder,
   83         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         125  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   84    126   
                    "ValidationException",
   85    127   
                );
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   86    129   
                let content_length = payload.len();
   87    130   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   88    131   
                    builder,
   89         -
                    ::http::header::CONTENT_LENGTH,
         132  +
                    ::http_1x::header::CONTENT_LENGTH,
   90    133   
                    content_length,
   91    134   
                );
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   92    136   
                builder
   93    137   
                    .status(400)
   94    138   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   95         -
            }
         139  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         140  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   96    141   
        }
         142  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   97    143   
    })
         144  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   98    145   
}
   99    146   
         147  +
/* JsonParserGenerator.kt:148 */
  100    148   
pub(crate) fn de_malformed_timestamp_body_http_date(
  101    149   
    value: &[u8],
  102    150   
    mut builder: crate::input::malformed_timestamp_body_http_date_input::Builder,
  103    151   
) -> ::std::result::Result<
  104    152   
    crate::input::malformed_timestamp_body_http_date_input::Builder,
  105    153   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  106    154   
> {
         155  +
    /* JsonParserGenerator.kt:153 */
  107    156   
    let mut tokens_owned =
  108    157   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  109    158   
            .peekable();
  110    159   
    let tokens = &mut tokens_owned;
  111    160   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         161  +
    /* JsonParserGenerator.kt:684 */
  112    162   
    loop {
         163  +
        /* JsonParserGenerator.kt:685 */
  113    164   
        match tokens.next().transpose()? {
         165  +
            /* JsonParserGenerator.kt:686 */
  114    166   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  115    167   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         168  +
                /* JsonParserGenerator.kt:260 */
  116    169   
                match key.to_unescaped()?.as_ref() {
         170  +
                    /* JsonParserGenerator.kt:262 */
  117    171   
                    "timestamp" => {
         172  +
                        /* JsonParserGenerator.kt:276 */
  118    173   
                        if let Some(v) =
         174  +
                            /* JsonParserGenerator.kt:384 */
  119    175   
                            ::aws_smithy_json::deserialize::token::expect_timestamp_or_null(
  120         -
                                tokens.next(),
  121         -
                                ::aws_smithy_types::date_time::Format::HttpDate,
  122         -
                            )?
         176  +
                                    tokens.next(),
         177  +
                                    ::aws_smithy_types::date_time::Format::HttpDate,
         178  +
                                )?
         179  +
                        /* JsonParserGenerator.kt:278 */
  123    180   
                        {
  124    181   
                            builder = builder.set_timestamp(v);
  125    182   
                        }
         183  +
                        /* JsonParserGenerator.kt:262 */
  126    184   
                    }
  127         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         185  +
                    /* JsonParserGenerator.kt:290 */
         186  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  128    187   
                }
         188  +
                /* JsonParserGenerator.kt:686 */
  129    189   
            }
         190  +
            /* JsonParserGenerator.kt:695 */
  130    191   
            other => {
  131    192   
                return Err(
  132    193   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  133    194   
                        "expected object key or end object, found: {other:?}"
  134    195   
                    )),
  135    196   
                )
  136         -
            }
         197  +
            } /* JsonParserGenerator.kt:685 */
  137    198   
        }
         199  +
        /* JsonParserGenerator.kt:684 */
  138    200   
    }
         201  +
    /* JsonParserGenerator.kt:250 */
  139    202   
    if tokens.next().is_some() {
         203  +
        /* JsonParserGenerator.kt:251 */
  140    204   
        return Err(
  141    205   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  142    206   
                "found more JSON tokens after completing parsing",
  143    207   
            ),
  144    208   
        );
         209  +
        /* JsonParserGenerator.kt:250 */
  145    210   
    }
         211  +
    /* JsonParserGenerator.kt:163 */
  146    212   
    Ok(builder)
         213  +
    /* JsonParserGenerator.kt:148 */
  147    214   
}

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

@@ -1,1 +94,135 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_header_date_time_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampHeaderDateTimeInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input =
   18     23   
            crate::input::malformed_timestamp_header_date_time_input::Builder::default();
          24  +
        /* RustType.kt:534 */
   19     25   
        #[allow(unused_variables)]
          26  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   20     27   
        let ::aws_smithy_runtime_api::http::RequestParts {
   21     28   
            uri, headers, body, ..
   22     29   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          30  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
   23     31   
        if let Some(value) = crate::protocol_serde::shape_malformed_timestamp_header_date_time_input::de_timestamp_header(&headers)? {
   24     32   
                                input = input.set_timestamp(value)
   25     33   
                            }
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   26     35   
        input.build()?
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   27     37   
    })
          38  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   28     39   
}
   29     40   
          41  +
/* RustType.kt:534 */
   30     42   
#[allow(clippy::unnecessary_wraps)]
          43  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   31     44   
pub fn ser_malformed_timestamp_header_date_time_http_response(
   32     45   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampHeaderDateTimeOutput,
   33     46   
) -> std::result::Result<
   34     47   
    ::aws_smithy_http_server::response::Response,
   35     48   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   36     49   
> {
          50  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   37     51   
    Ok({
          52  +
        /* RustType.kt:534 */
   38     53   
        #[allow(unused_mut)]
   39         -
        let mut builder = ::http::Response::builder();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          55  +
        let mut builder = ::http_1x::Response::builder();
          56  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   40     57   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   41     58   
            builder,
   42         -
            ::http::header::CONTENT_TYPE,
          59  +
            ::http_1x::header::CONTENT_TYPE,
   43     60   
            "application/json",
   44     61   
        );
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   45     63   
        let http_status: u16 = 200;
   46     64   
        builder = builder.status(http_status);
   47         -
        let payload = "";
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          66  +
        let payload =
          67  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   48     70   
        let content_length = payload.len();
   49     71   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   50     72   
            builder,
   51         -
            ::http::header::CONTENT_LENGTH,
          73  +
            ::http_1x::header::CONTENT_LENGTH,
   52     74   
            content_length,
   53     75   
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   54     77   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   55     79   
        builder.body(body)?
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   56     81   
    })
          82  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   57     83   
}
   58     84   
          85  +
/* RustType.kt:534 */
   59     86   
#[allow(clippy::unnecessary_wraps)]
          87  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   60     88   
pub fn ser_malformed_timestamp_header_date_time_http_error(
   61     89   
    error: &crate::error::MalformedTimestampHeaderDateTimeError,
   62     90   
) -> std::result::Result<
   63     91   
    ::aws_smithy_http_server::response::Response,
   64     92   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   65     93   
> {
          94  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   66     95   
    Ok({
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   67     97   
        match error {
          98  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   68     99   
            crate::error::MalformedTimestampHeaderDateTimeError::ValidationException(output) => {
         100  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   69    101   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         102  +
                /* RustType.kt:534 */
   70    103   
                #[allow(unused_mut)]
   71         -
                let mut builder = ::http::Response::builder();
         104  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         105  +
                let mut builder = ::http_1x::Response::builder();
         106  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   72    107   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   73    108   
                    builder,
   74         -
                    ::http::header::CONTENT_TYPE,
         109  +
                    ::http_1x::header::CONTENT_TYPE,
   75    110   
                    "application/json",
   76    111   
                );
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   77    113   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   78    114   
                    builder,
   79         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         115  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   80    116   
                    "ValidationException",
   81    117   
                );
         118  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   82    119   
                let content_length = payload.len();
   83    120   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   84    121   
                    builder,
   85         -
                    ::http::header::CONTENT_LENGTH,
         122  +
                    ::http_1x::header::CONTENT_LENGTH,
   86    123   
                    content_length,
   87    124   
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   88    126   
                builder
   89    127   
                    .status(400)
   90    128   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   91         -
            }
         129  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         130  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   92    131   
        }
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   93    133   
    })
         134  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   94    135   
}

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

@@ -1,1 +22,25 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_timestamp_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::aws_smithy_types::DateTime>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
    8     10   
    let headers = header_map.get_all("timestamp");
    9         -
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(
   10         -
        headers,
   11         -
        ::aws_smithy_types::date_time::Format::DateTime,
   12         -
    )?;
          11  +
    /* HttpBindingGenerator.kt:417 */
          12  +
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::DateTime)?
          13  +
    /* HttpBindingGenerator.kt:425 */;
          14  +
    /* HttpBindingGenerator.kt:491 */
   13     15   
    if var_1.len() > 1 {
   14     16   
        Err(::aws_smithy_http::header::ParseError::new(format!(
   15     17   
            "expected one item but found {}",
   16     18   
            var_1.len()
   17     19   
        )))
   18     20   
    } else {
   19     21   
        let mut var_1 = var_1;
   20     22   
        Ok(var_1.pop())
   21     23   
    }
          24  +
    /* HttpBindingGenerator.kt:159 */
   22     25   
}

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

@@ -1,1 +93,134 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_header_default_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampHeaderDefaultInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_header_default_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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:856 */
   22     30   
        if let Some(value) = crate::protocol_serde::shape_malformed_timestamp_header_default_input::de_timestamp_header(&headers)? {
   23     31   
                                input = input.set_timestamp(value)
   24     32   
                            }
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   25     34   
        input.build()?
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   26     36   
    })
          37  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   27     38   
}
   28     39   
          40  +
/* RustType.kt:534 */
   29     41   
#[allow(clippy::unnecessary_wraps)]
          42  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   30     43   
pub fn ser_malformed_timestamp_header_default_http_response(
   31     44   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampHeaderDefaultOutput,
   32     45   
) -> std::result::Result<
   33     46   
    ::aws_smithy_http_server::response::Response,
   34     47   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   35     48   
> {
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   36     50   
    Ok({
          51  +
        /* RustType.kt:534 */
   37     52   
        #[allow(unused_mut)]
   38         -
        let mut builder = ::http::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          54  +
        let mut builder = ::http_1x::Response::builder();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   39     56   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   40     57   
            builder,
   41         -
            ::http::header::CONTENT_TYPE,
          58  +
            ::http_1x::header::CONTENT_TYPE,
   42     59   
            "application/json",
   43     60   
        );
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   44     62   
        let http_status: u16 = 200;
   45     63   
        builder = builder.status(http_status);
   46         -
        let payload = "";
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          65  +
        let payload =
          66  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   47     69   
        let content_length = payload.len();
   48     70   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     71   
            builder,
   50         -
            ::http::header::CONTENT_LENGTH,
          72  +
            ::http_1x::header::CONTENT_LENGTH,
   51     73   
            content_length,
   52     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   53     76   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   54     78   
        builder.body(body)?
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   55     80   
    })
          81  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   56     82   
}
   57     83   
          84  +
/* RustType.kt:534 */
   58     85   
#[allow(clippy::unnecessary_wraps)]
          86  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   59     87   
pub fn ser_malformed_timestamp_header_default_http_error(
   60     88   
    error: &crate::error::MalformedTimestampHeaderDefaultError,
   61     89   
) -> std::result::Result<
   62     90   
    ::aws_smithy_http_server::response::Response,
   63     91   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   64     92   
> {
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   65     94   
    Ok({
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   66     96   
        match error {
          97  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   67     98   
            crate::error::MalformedTimestampHeaderDefaultError::ValidationException(output) => {
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   68    100   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         101  +
                /* RustType.kt:534 */
   69    102   
                #[allow(unused_mut)]
   70         -
                let mut builder = ::http::Response::builder();
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         104  +
                let mut builder = ::http_1x::Response::builder();
         105  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   71    106   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   72    107   
                    builder,
   73         -
                    ::http::header::CONTENT_TYPE,
         108  +
                    ::http_1x::header::CONTENT_TYPE,
   74    109   
                    "application/json",
   75    110   
                );
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   76    112   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    113   
                    builder,
   78         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         114  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   79    115   
                    "ValidationException",
   80    116   
                );
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   81    118   
                let content_length = payload.len();
   82    119   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    120   
                    builder,
   84         -
                    ::http::header::CONTENT_LENGTH,
         121  +
                    ::http_1x::header::CONTENT_LENGTH,
   85    122   
                    content_length,
   86    123   
                );
         124  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   87    125   
                builder
   88    126   
                    .status(400)
   89    127   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   90         -
            }
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         129  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   91    130   
        }
         131  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   92    132   
    })
         133  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   93    134   
}

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

@@ -1,1 +22,25 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_timestamp_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::aws_smithy_types::DateTime>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
    8     10   
    let headers = header_map.get_all("timestamp");
    9         -
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(
   10         -
        headers,
   11         -
        ::aws_smithy_types::date_time::Format::HttpDate,
   12         -
    )?;
          11  +
    /* HttpBindingGenerator.kt:417 */
          12  +
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::HttpDate)?
          13  +
    /* HttpBindingGenerator.kt:425 */;
          14  +
    /* HttpBindingGenerator.kt:491 */
   13     15   
    if var_1.len() > 1 {
   14     16   
        Err(::aws_smithy_http::header::ParseError::new(format!(
   15     17   
            "expected one item but found {}",
   16     18   
            var_1.len()
   17     19   
        )))
   18     20   
    } else {
   19     21   
        let mut var_1 = var_1;
   20     22   
        Ok(var_1.pop())
   21     23   
    }
          24  +
    /* HttpBindingGenerator.kt:159 */
   22     25   
}

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

@@ -1,1 +93,134 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_header_epoch_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampHeaderEpochInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_header_epoch_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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:856 */
   22     30   
        if let Some(value) = crate::protocol_serde::shape_malformed_timestamp_header_epoch_input::de_timestamp_header(&headers)? {
   23     31   
                                input = input.set_timestamp(value)
   24     32   
                            }
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   25     34   
        input.build()?
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   26     36   
    })
          37  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   27     38   
}
   28     39   
          40  +
/* RustType.kt:534 */
   29     41   
#[allow(clippy::unnecessary_wraps)]
          42  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   30     43   
pub fn ser_malformed_timestamp_header_epoch_http_response(
   31     44   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampHeaderEpochOutput,
   32     45   
) -> std::result::Result<
   33     46   
    ::aws_smithy_http_server::response::Response,
   34     47   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   35     48   
> {
          49  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   36     50   
    Ok({
          51  +
        /* RustType.kt:534 */
   37     52   
        #[allow(unused_mut)]
   38         -
        let mut builder = ::http::Response::builder();
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          54  +
        let mut builder = ::http_1x::Response::builder();
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   39     56   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   40     57   
            builder,
   41         -
            ::http::header::CONTENT_TYPE,
          58  +
            ::http_1x::header::CONTENT_TYPE,
   42     59   
            "application/json",
   43     60   
        );
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   44     62   
        let http_status: u16 = 200;
   45     63   
        builder = builder.status(http_status);
   46         -
        let payload = "";
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          65  +
        let payload =
          66  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   47     69   
        let content_length = payload.len();
   48     70   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   49     71   
            builder,
   50         -
            ::http::header::CONTENT_LENGTH,
          72  +
            ::http_1x::header::CONTENT_LENGTH,
   51     73   
            content_length,
   52     74   
        );
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   53     76   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   54     78   
        builder.body(body)?
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   55     80   
    })
          81  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   56     82   
}
   57     83   
          84  +
/* RustType.kt:534 */
   58     85   
#[allow(clippy::unnecessary_wraps)]
          86  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   59     87   
pub fn ser_malformed_timestamp_header_epoch_http_error(
   60     88   
    error: &crate::error::MalformedTimestampHeaderEpochError,
   61     89   
) -> std::result::Result<
   62     90   
    ::aws_smithy_http_server::response::Response,
   63     91   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   64     92   
> {
          93  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   65     94   
    Ok({
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   66     96   
        match error {
          97  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   67     98   
            crate::error::MalformedTimestampHeaderEpochError::ValidationException(output) => {
          99  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   68    100   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         101  +
                /* RustType.kt:534 */
   69    102   
                #[allow(unused_mut)]
   70         -
                let mut builder = ::http::Response::builder();
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         104  +
                let mut builder = ::http_1x::Response::builder();
         105  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   71    106   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   72    107   
                    builder,
   73         -
                    ::http::header::CONTENT_TYPE,
         108  +
                    ::http_1x::header::CONTENT_TYPE,
   74    109   
                    "application/json",
   75    110   
                );
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   76    112   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    113   
                    builder,
   78         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         114  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   79    115   
                    "ValidationException",
   80    116   
                );
         117  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   81    118   
                let content_length = payload.len();
   82    119   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    120   
                    builder,
   84         -
                    ::http::header::CONTENT_LENGTH,
         121  +
                    ::http_1x::header::CONTENT_LENGTH,
   85    122   
                    content_length,
   86    123   
                );
         124  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
   87    125   
                builder
   88    126   
                    .status(400)
   89    127   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   90         -
            }
         128  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         129  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
   91    130   
        }
         131  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
   92    132   
    })
         133  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
   93    134   
}

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

@@ -1,1 +22,25 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:159 */
    2      3   
pub(crate) fn de_timestamp_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<
    5      6   
    ::std::option::Option<::aws_smithy_types::DateTime>,
    6      7   
    ::aws_smithy_http::header::ParseError,
    7      8   
> {
           9  +
    /* HttpBindingGenerator.kt:166 */
    8     10   
    let headers = header_map.get_all("timestamp");
    9         -
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(
   10         -
        headers,
   11         -
        ::aws_smithy_types::date_time::Format::EpochSeconds,
   12         -
    )?;
          11  +
    /* HttpBindingGenerator.kt:417 */
          12  +
    let var_1: Vec<::aws_smithy_types::DateTime> = ::aws_smithy_http::header::many_dates(headers, ::aws_smithy_types::date_time::Format::EpochSeconds)?
          13  +
    /* HttpBindingGenerator.kt:425 */;
          14  +
    /* HttpBindingGenerator.kt:491 */
   13     15   
    if var_1.len() > 1 {
   14     16   
        Err(::aws_smithy_http::header::ParseError::new(format!(
   15     17   
            "expected one item but found {}",
   16     18   
            var_1.len()
   17     19   
        )))
   18     20   
    } else {
   19     21   
        let mut var_1 = var_1;
   20     22   
        Ok(var_1.pop())
   21     23   
    }
          24  +
    /* HttpBindingGenerator.kt:159 */
   22     25   
}

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

@@ -1,1 +111,154 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:534 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:408 */
    3      5   
pub async fn de_malformed_timestamp_path_default_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           6  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedTimestampPathDefaultInput,
    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:424 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:534 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:759 */
   17     22   
        let mut input = crate::input::malformed_timestamp_path_default_input::Builder::default();
          23  +
        /* RustType.kt:534 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
   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:1134 */
   22     30   
        let input_string = uri.path();
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:1146 */
   23     32   
        let (input_string, (_, m1)) =
   24     33   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   25     34   
                ::nom::sequence::preceded(
   26     35   
                    ::nom::bytes::complete::tag("/"),
   27     36   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   28     37   
                        "MalformedTimestampPathDefault",
   29     38   
                    ),
   30     39   
                ),
   31     40   
                ::nom::sequence::preceded(
   32     41   
                    ::nom::bytes::complete::tag("/"),
   33     42   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   34     43   
                        ::nom::bytes::complete::take_until("/"),
   35     44   
                        ::nom::combinator::rest,
   36     45   
                    )),
   37     46   
                ),
   38     47   
            ))(input_string)?;
   39     48   
        debug_assert_eq!("", input_string);
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:1157 */
   40     50   
        input = input.set_timestamp(
   41     51   
            crate::protocol_serde::shape_malformed_timestamp_path_default_input::de_timestamp(m1)?,
   42     52   
        );
          53  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
   43     54   
        input.build()?
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
   44     56   
    })
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
   45     58   
}
   46     59   
          60  +
/* RustType.kt:534 */
   47     61   
#[allow(clippy::unnecessary_wraps)]
          62  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
   48     63   
pub fn ser_malformed_timestamp_path_default_http_response(
   49     64   
    #[allow(unused_variables)] output: crate::output::MalformedTimestampPathDefaultOutput,
   50     65   
) -> std::result::Result<
   51     66   
    ::aws_smithy_http_server::response::Response,
   52     67   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   53     68   
> {
          69  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
   54     70   
    Ok({
          71  +
        /* RustType.kt:534 */
   55     72   
        #[allow(unused_mut)]
   56         -
        let mut builder = ::http::Response::builder();
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          74  +
        let mut builder = ::http_1x::Response::builder();
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
   57     76   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   58     77   
            builder,
   59         -
            ::http::header::CONTENT_TYPE,
          78  +
            ::http_1x::header::CONTENT_TYPE,
   60     79   
            "application/json",
   61     80   
        );
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
   62     82   
        let http_status: u16 = 200;
   63     83   
        builder = builder.status(http_status);
   64         -
        let payload = "";
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          85  +
        let payload =
          86  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
   65     89   
        let content_length = payload.len();
   66     90   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   67     91   
            builder,
   68         -
            ::http::header::CONTENT_LENGTH,
          92  +
            ::http_1x::header::CONTENT_LENGTH,
   69     93   
            content_length,
   70     94   
        );
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
   71     96   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          97  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
   72     98   
        builder.body(body)?
          99  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
   73    100   
    })
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
   74    102   
}
   75    103   
         104  +
/* RustType.kt:534 */
   76    105   
#[allow(clippy::unnecessary_wraps)]
         106  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
   77    107   
pub fn ser_malformed_timestamp_path_default_http_error(
   78    108   
    error: &crate::error::MalformedTimestampPathDefaultError,
   79    109   
) -> std::result::Result<
   80    110   
    ::aws_smithy_http_server::response::Response,
   81    111   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    112   
> {
         113  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
   83    114   
    Ok({
         115  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
   84    116   
        match error {
         117  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
   85    118   
            crate::error::MalformedTimestampPathDefaultError::ValidationException(output) => {
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
   86    120   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         121  +
                /* RustType.kt:534 */
   87    122   
                #[allow(unused_mut)]
   88         -
                let mut builder = ::http::Response::builder();
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         124  +
                let mut builder = ::http_1x::Response::builder();
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   89    126   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   90    127   
                    builder,
   91         -
                    ::http::header::CONTENT_TYPE,
         128  +
                    ::http_1x::header::CONTENT_TYPE,
   92    129   
                    "application/json",
   93    130   
                );
         131  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
   94    132   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   95    133   
                    builder,
   96         -
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         134  +
                    ::http_1x::header::HeaderName::from_static("x-amzn-errortype"),
   97    135   
                    "ValidationException",
   98    136   
                );
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
   99    138   
                let content_length = payload.len();
  100    139   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  101    140   
                    builder,
  102         -
                    ::http::header::CONTENT_LENGTH,
         141  +
                    ::http_1x::header::CONTENT_LENGTH,
  103    142   
                    content_length,
  104    143   
                );
         144  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
  105    145   
                builder
  106    146   
                    .status(400)
  107    147   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
  108         -
            }
         148  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         149  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
  109    150   
        }
         151  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
  110    152   
    })
         153  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
  111    154   
}

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

@@ -1,1 +14,16 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
    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   
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1486 */
    8     10   
    let value = ::percent_encoding::percent_decode_str(value).decode_utf8()?;
    9         -
    let value = ::aws_smithy_types::DateTime::from_str(
   10         -
        value.as_ref(),
   11         -
        ::aws_smithy_types::date_time::Format::DateTime,
   12         -
    )?;
          11  +
    let value = ::aws_smithy_types::DateTime::from_str(value.as_ref(), ::aws_smithy_types::date_time::Format::DateTime)?
          12  +
    /* ServerHttpBoundProtocolGenerator.kt:1510 */;
          13  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
   13     14   
    Ok(value)
          15  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
   14     16   
}