Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

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

@@ -1,1 +186,258 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_float_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedFloatInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_float_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_float::de_malformed_float(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_header_header(&headers)?
   35     47   
        {
   36     48   
            input = input.set_float_in_header(Some(value))
   37     49   
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   38     51   
        let input_string = uri.path();
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   39     53   
        let (input_string, (_, m1)) =
   40     54   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     55   
                ::nom::sequence::preceded(
   42     56   
                    ::nom::bytes::complete::tag("/"),
   43     57   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   44     58   
                        "MalformedFloat",
   45     59   
                    ),
   46     60   
                ),
   47     61   
                ::nom::sequence::preceded(
   48     62   
                    ::nom::bytes::complete::tag("/"),
   49     63   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   50     64   
                        ::nom::bytes::complete::take_until("/"),
   51     65   
                        ::nom::combinator::rest,
   52     66   
                    )),
   53     67   
                ),
   54     68   
            ))(input_string)?;
   55     69   
        debug_assert_eq!("", input_string);
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   56     71   
        input = input.set_float_in_path(
   57     72   
            crate::protocol_serde::shape_malformed_float_input::de_float_in_path(m1)?,
   58     73   
        );
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   59     75   
        let query_string = uri.query().unwrap_or("");
   60     76   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   61     78   
        let mut float_in_query_seen = false;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   62     80   
        for (k, v) in pairs {
          81  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   63     82   
            if !float_in_query_seen && k == "floatInQuery" {
   64     83   
                input = input.set_float_in_query(
   65     84   
                    crate::protocol_serde::shape_malformed_float_input::de_float_in_query(&v)?,
   66     85   
                );
   67     86   
                float_in_query_seen = true;
   68     87   
            }
          88  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   69     89   
        }
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   70     91   
        input.build()?
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   71     93   
    })
          94  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   72     95   
}
   73     96   
          97  +
/* RustType.kt:516 */
   74     98   
#[allow(clippy::unnecessary_wraps)]
          99  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   75    100   
pub fn ser_malformed_float_http_response(
   76    101   
    #[allow(unused_variables)] output: crate::output::MalformedFloatOutput,
   77    102   
) -> std::result::Result<
   78    103   
    ::aws_smithy_http_server::response::Response,
   79    104   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   80    105   
> {
         106  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   81    107   
    Ok({
         108  +
        /* RustType.kt:516 */
   82    109   
        #[allow(unused_mut)]
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   83    111   
        let mut builder = ::http::Response::builder();
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    113   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    114   
            builder,
   86    115   
            ::http::header::CONTENT_TYPE,
   87    116   
            "application/json",
   88    117   
        );
         118  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   89    119   
        let http_status: u16 = 200;
   90    120   
        builder = builder.status(http_status);
   91         -
        let payload = "";
         121  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         122  +
        let payload =
         123  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         124  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         125  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   92    126   
        let content_length = payload.len();
   93    127   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   94    128   
            builder,
   95    129   
            ::http::header::CONTENT_LENGTH,
   96    130   
            content_length,
   97    131   
        );
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   98    133   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   99    135   
        builder.body(body)?
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  100    137   
    })
         138  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  101    139   
}
  102    140   
         141  +
/* RustType.kt:516 */
  103    142   
#[allow(clippy::unnecessary_wraps)]
         143  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  104    144   
pub fn ser_malformed_float_http_error(
  105    145   
    error: &crate::error::MalformedFloatError,
  106    146   
) -> std::result::Result<
  107    147   
    ::aws_smithy_http_server::response::Response,
  108    148   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  109    149   
> {
         150  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  110    151   
    Ok({
         152  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  111    153   
        match error {
         154  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  112    155   
            crate::error::MalformedFloatError::ValidationException(output) => {
         156  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  113    157   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         158  +
                /* RustType.kt:516 */
  114    159   
                #[allow(unused_mut)]
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  115    161   
                let mut builder = ::http::Response::builder();
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  116    163   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  117    164   
                    builder,
  118    165   
                    ::http::header::CONTENT_TYPE,
  119    166   
                    "application/json",
  120    167   
                );
         168  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  121    169   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  122    170   
                    builder,
  123    171   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  124    172   
                    "ValidationException",
  125    173   
                );
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  126    175   
                let content_length = payload.len();
  127    176   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  128    177   
                    builder,
  129    178   
                    ::http::header::CONTENT_LENGTH,
  130    179   
                    content_length,
  131    180   
                );
         181  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  132    182   
                builder
  133    183   
                    .status(400)
  134    184   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         185  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         186  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  135    187   
        }
  136         -
        }
         188  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  137    189   
    })
         190  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  138    191   
}
  139    192   
         193  +
/* JsonParserGenerator.kt:148 */
  140    194   
pub(crate) fn de_malformed_float(
  141    195   
    value: &[u8],
  142    196   
    mut builder: crate::input::malformed_float_input::Builder,
  143    197   
) -> ::std::result::Result<
  144    198   
    crate::input::malformed_float_input::Builder,
  145    199   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  146    200   
> {
         201  +
    /* JsonParserGenerator.kt:153 */
  147    202   
    let mut tokens_owned =
  148    203   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  149    204   
            .peekable();
  150    205   
    let tokens = &mut tokens_owned;
  151    206   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         207  +
    /* JsonParserGenerator.kt:684 */
  152    208   
    loop {
         209  +
        /* JsonParserGenerator.kt:685 */
  153    210   
        match tokens.next().transpose()? {
         211  +
            /* JsonParserGenerator.kt:686 */
  154    212   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  155    213   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         214  +
                /* JsonParserGenerator.kt:260 */
  156    215   
                match key.to_unescaped()?.as_ref() {
         216  +
                    /* JsonParserGenerator.kt:262 */
  157    217   
                    "floatInBody" => {
         218  +
                        /* JsonParserGenerator.kt:272 */
  158    219   
                        builder = builder.set_float_in_body(
         220  +
                            /* JsonParserGenerator.kt:361 */
  159    221   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  160    222   
                                tokens.next(),
  161    223   
                            )?
  162         -
                            .map(|v| v.to_f32_lossy()),
         224  +
                            .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
  163    225   
                        );
         226  +
                        /* JsonParserGenerator.kt:262 */
  164    227   
                    }
  165         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         228  +
                    /* JsonParserGenerator.kt:290 */
         229  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  166    230   
                }
         231  +
                /* JsonParserGenerator.kt:686 */
  167    232   
            }
         233  +
            /* JsonParserGenerator.kt:695 */
  168    234   
            other => {
  169    235   
                return Err(
  170    236   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  171    237   
                        "expected object key or end object, found: {:?}",
  172    238   
                        other
  173    239   
                    )),
  174    240   
                )
         241  +
            } /* JsonParserGenerator.kt:685 */
  175    242   
        }
         243  +
        /* JsonParserGenerator.kt:684 */
  176    244   
    }
  177         -
    }
         245  +
    /* JsonParserGenerator.kt:250 */
  178    246   
    if tokens.next().is_some() {
         247  +
        /* JsonParserGenerator.kt:251 */
  179    248   
        return Err(
  180    249   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  181    250   
                "found more JSON tokens after completing parsing",
  182    251   
            ),
  183    252   
        );
         253  +
        /* JsonParserGenerator.kt:250 */
  184    254   
    }
         255  +
    /* JsonParserGenerator.kt:163 */
  185    256   
    Ok(builder)
         257  +
    /* JsonParserGenerator.kt:148 */
  186    258   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_float_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<f32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("floatInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<f32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    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:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_float_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    f32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_float_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<f32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

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

@@ -1,1 +189,261 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_integer_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedIntegerInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_integer_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_integer::de_malformed_integer(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_header_header(
   35     47   
                &headers,
   36     48   
            )?
   37     49   
        {
   38     50   
            input = input.set_integer_in_header(Some(value))
   39     51   
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   40     53   
        let input_string = uri.path();
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   41     55   
        let (input_string, (_, m1)) =
   42     56   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   43     57   
                ::nom::sequence::preceded(
   44     58   
                    ::nom::bytes::complete::tag("/"),
   45     59   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
   46     60   
                        "MalformedInteger",
   47     61   
                    ),
   48     62   
                ),
   49     63   
                ::nom::sequence::preceded(
   50     64   
                    ::nom::bytes::complete::tag("/"),
   51     65   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   52     66   
                        ::nom::bytes::complete::take_until("/"),
   53     67   
                        ::nom::combinator::rest,
   54     68   
                    )),
   55     69   
                ),
   56     70   
            ))(input_string)?;
   57     71   
        debug_assert_eq!("", input_string);
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   58     73   
        input = input.set_integer_in_path(
   59     74   
            crate::protocol_serde::shape_malformed_integer_input::de_integer_in_path(m1)?,
   60     75   
        );
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   61     77   
        let query_string = uri.query().unwrap_or("");
   62     78   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   63     80   
        let mut integer_in_query_seen = false;
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   64     82   
        for (k, v) in pairs {
          83  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   65     84   
            if !integer_in_query_seen && k == "integerInQuery" {
   66     85   
                input = input.set_integer_in_query(
   67     86   
                    crate::protocol_serde::shape_malformed_integer_input::de_integer_in_query(&v)?,
   68     87   
                );
   69     88   
                integer_in_query_seen = true;
   70     89   
            }
          90  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   71     91   
        }
          92  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   72     93   
        input.build()?
          94  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   73     95   
    })
          96  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   74     97   
}
   75     98   
          99  +
/* RustType.kt:516 */
   76    100   
#[allow(clippy::unnecessary_wraps)]
         101  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   77    102   
pub fn ser_malformed_integer_http_response(
   78    103   
    #[allow(unused_variables)] output: crate::output::MalformedIntegerOutput,
   79    104   
) -> std::result::Result<
   80    105   
    ::aws_smithy_http_server::response::Response,
   81    106   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   82    107   
> {
         108  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   83    109   
    Ok({
         110  +
        /* RustType.kt:516 */
   84    111   
        #[allow(unused_mut)]
         112  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   85    113   
        let mut builder = ::http::Response::builder();
         114  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   86    115   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   87    116   
            builder,
   88    117   
            ::http::header::CONTENT_TYPE,
   89    118   
            "application/json",
   90    119   
        );
         120  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   91    121   
        let http_status: u16 = 200;
   92    122   
        builder = builder.status(http_status);
   93         -
        let payload = "";
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         124  +
        let payload =
         125  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         126  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         127  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   94    128   
        let content_length = payload.len();
   95    129   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    130   
            builder,
   97    131   
            ::http::header::CONTENT_LENGTH,
   98    132   
            content_length,
   99    133   
        );
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
  100    135   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         136  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
  101    137   
        builder.body(body)?
         138  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
  102    139   
    })
         140  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
  103    141   
}
  104    142   
         143  +
/* RustType.kt:516 */
  105    144   
#[allow(clippy::unnecessary_wraps)]
         145  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  106    146   
pub fn ser_malformed_integer_http_error(
  107    147   
    error: &crate::error::MalformedIntegerError,
  108    148   
) -> std::result::Result<
  109    149   
    ::aws_smithy_http_server::response::Response,
  110    150   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  111    151   
> {
         152  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  112    153   
    Ok({
         154  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  113    155   
        match error {
         156  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  114    157   
            crate::error::MalformedIntegerError::ValidationException(output) => {
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  115    159   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         160  +
                /* RustType.kt:516 */
  116    161   
                #[allow(unused_mut)]
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  117    163   
                let mut builder = ::http::Response::builder();
         164  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  118    165   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  119    166   
                    builder,
  120    167   
                    ::http::header::CONTENT_TYPE,
  121    168   
                    "application/json",
  122    169   
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  123    171   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  124    172   
                    builder,
  125    173   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  126    174   
                    "ValidationException",
  127    175   
                );
         176  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  128    177   
                let content_length = payload.len();
  129    178   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  130    179   
                    builder,
  131    180   
                    ::http::header::CONTENT_LENGTH,
  132    181   
                    content_length,
  133    182   
                );
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  134    184   
                builder
  135    185   
                    .status(400)
  136    186   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         187  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         188  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  137    189   
        }
  138         -
        }
         190  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  139    191   
    })
         192  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  140    193   
}
  141    194   
         195  +
/* JsonParserGenerator.kt:148 */
  142    196   
pub(crate) fn de_malformed_integer(
  143    197   
    value: &[u8],
  144    198   
    mut builder: crate::input::malformed_integer_input::Builder,
  145    199   
) -> ::std::result::Result<
  146    200   
    crate::input::malformed_integer_input::Builder,
  147    201   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  148    202   
> {
         203  +
    /* JsonParserGenerator.kt:153 */
  149    204   
    let mut tokens_owned =
  150    205   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  151    206   
            .peekable();
  152    207   
    let tokens = &mut tokens_owned;
  153    208   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         209  +
    /* JsonParserGenerator.kt:684 */
  154    210   
    loop {
         211  +
        /* JsonParserGenerator.kt:685 */
  155    212   
        match tokens.next().transpose()? {
         213  +
            /* JsonParserGenerator.kt:686 */
  156    214   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  157    215   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         216  +
                /* JsonParserGenerator.kt:260 */
  158    217   
                match key.to_unescaped()?.as_ref() {
         218  +
                    /* JsonParserGenerator.kt:262 */
  159    219   
                    "integerInBody" => {
         220  +
                        /* JsonParserGenerator.kt:272 */
  160    221   
                        builder = builder.set_integer_in_body(
         222  +
                            /* JsonParserGenerator.kt:365 */
  161    223   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  162    224   
                                tokens.next(),
  163    225   
                            )?
  164    226   
                            .map(i32::try_from)
  165         -
                            .transpose()?,
         227  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  166    228   
                        );
         229  +
                        /* JsonParserGenerator.kt:262 */
  167    230   
                    }
  168         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         231  +
                    /* JsonParserGenerator.kt:290 */
         232  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  169    233   
                }
         234  +
                /* JsonParserGenerator.kt:686 */
  170    235   
            }
         236  +
            /* JsonParserGenerator.kt:695 */
  171    237   
            other => {
  172    238   
                return Err(
  173    239   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  174    240   
                        "expected object key or end object, found: {:?}",
  175    241   
                        other
  176    242   
                    )),
  177    243   
                )
         244  +
            } /* JsonParserGenerator.kt:685 */
  178    245   
        }
         246  +
        /* JsonParserGenerator.kt:684 */
  179    247   
    }
  180         -
    }
         248  +
    /* JsonParserGenerator.kt:250 */
  181    249   
    if tokens.next().is_some() {
         250  +
        /* JsonParserGenerator.kt:251 */
  182    251   
        return Err(
  183    252   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  184    253   
                "found more JSON tokens after completing parsing",
  185    254   
            ),
  186    255   
        );
         256  +
        /* JsonParserGenerator.kt:250 */
  187    257   
    }
         258  +
    /* JsonParserGenerator.kt:163 */
  188    259   
    Ok(builder)
         260  +
    /* JsonParserGenerator.kt:148 */
  189    261   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_integer_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i32>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("integerInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i32>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    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:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_integer_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i32,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_integer_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i32>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

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

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

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

@@ -1,1 +185,257 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_long_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::MalformedLongInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_long_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_malformed_long::de_malformed_long(
   29     39   
                bytes.as_ref(),
   30     40   
                input,
   31     41   
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   32     43   
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   33     45   
        if let Some(value) =
   34     46   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_header_header(&headers)?
   35     47   
        {
   36     48   
            input = input.set_long_in_header(Some(value))
   37     49   
        }
          50  +
        /* ServerHttpBoundProtocolGenerator.kt:986 */
   38     51   
        let input_string = uri.path();
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:998 */
   39     53   
        let (input_string, (_, m1)) =
   40     54   
            ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
   41     55   
                ::nom::sequence::preceded(
   42     56   
                    ::nom::bytes::complete::tag("/"),
   43     57   
                    ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("MalformedLong"),
   44     58   
                ),
   45     59   
                ::nom::sequence::preceded(
   46     60   
                    ::nom::bytes::complete::tag("/"),
   47     61   
                    ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
   48     62   
                        ::nom::bytes::complete::take_until("/"),
   49     63   
                        ::nom::combinator::rest,
   50     64   
                    )),
   51     65   
                ),
   52     66   
            ))(input_string)?;
   53     67   
        debug_assert_eq!("", input_string);
          68  +
        /* ServerHttpBoundProtocolGenerator.kt:1009 */
   54     69   
        input = input.set_long_in_path(
   55     70   
            crate::protocol_serde::shape_malformed_long_input::de_long_in_path(m1)?,
   56     71   
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:1073 */
   57     73   
        let query_string = uri.query().unwrap_or("");
   58     74   
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:1099 */
   59     76   
        let mut long_in_query_seen = false;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:1105 */
   60     78   
        for (k, v) in pairs {
          79  +
            /* ServerHttpBoundProtocolGenerator.kt:1109 */
   61     80   
            if !long_in_query_seen && k == "longInQuery" {
   62     81   
                input = input.set_long_in_query(
   63     82   
                    crate::protocol_serde::shape_malformed_long_input::de_long_in_query(&v)?,
   64     83   
                );
   65     84   
                long_in_query_seen = true;
   66     85   
            }
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1105 */
   67     87   
        }
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   68     89   
        input.build()?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   69     91   
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   70     93   
}
   71     94   
          95  +
/* RustType.kt:516 */
   72     96   
#[allow(clippy::unnecessary_wraps)]
          97  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   73     98   
pub fn ser_malformed_long_http_response(
   74     99   
    #[allow(unused_variables)] output: crate::output::MalformedLongOutput,
   75    100   
) -> std::result::Result<
   76    101   
    ::aws_smithy_http_server::response::Response,
   77    102   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   78    103   
> {
         104  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   79    105   
    Ok({
         106  +
        /* RustType.kt:516 */
   80    107   
        #[allow(unused_mut)]
         108  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   81    109   
        let mut builder = ::http::Response::builder();
         110  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   82    111   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    112   
            builder,
   84    113   
            ::http::header::CONTENT_TYPE,
   85    114   
            "application/json",
   86    115   
        );
         116  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   87    117   
        let http_status: u16 = 200;
   88    118   
        builder = builder.status(http_status);
   89         -
        let payload = "";
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
         120  +
        let payload =
         121  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
         122  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
         123  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   90    124   
        let content_length = payload.len();
   91    125   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   92    126   
            builder,
   93    127   
            ::http::header::CONTENT_LENGTH,
   94    128   
            content_length,
   95    129   
        );
         130  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   96    131   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
         132  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   97    133   
        builder.body(body)?
         134  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   98    135   
    })
         136  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   99    137   
}
  100    138   
         139  +
/* RustType.kt:516 */
  101    140   
#[allow(clippy::unnecessary_wraps)]
         141  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
  102    142   
pub fn ser_malformed_long_http_error(
  103    143   
    error: &crate::error::MalformedLongError,
  104    144   
) -> std::result::Result<
  105    145   
    ::aws_smithy_http_server::response::Response,
  106    146   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
  107    147   
> {
         148  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
  108    149   
    Ok({
         150  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
  109    151   
        match error {
         152  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
  110    153   
            crate::error::MalformedLongError::ValidationException(output) => {
         154  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
  111    155   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         156  +
                /* RustType.kt:516 */
  112    157   
                #[allow(unused_mut)]
         158  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
  113    159   
                let mut builder = ::http::Response::builder();
         160  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  114    161   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  115    162   
                    builder,
  116    163   
                    ::http::header::CONTENT_TYPE,
  117    164   
                    "application/json",
  118    165   
                );
         166  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
  119    167   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  120    168   
                    builder,
  121    169   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
  122    170   
                    "ValidationException",
  123    171   
                );
         172  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  124    173   
                let content_length = payload.len();
  125    174   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  126    175   
                    builder,
  127    176   
                    ::http::header::CONTENT_LENGTH,
  128    177   
                    content_length,
  129    178   
                );
         179  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  130    180   
                builder
  131    181   
                    .status(400)
  132    182   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         183  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         184  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  133    185   
        }
  134         -
        }
         186  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  135    187   
    })
         188  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  136    189   
}
  137    190   
         191  +
/* JsonParserGenerator.kt:148 */
  138    192   
pub(crate) fn de_malformed_long(
  139    193   
    value: &[u8],
  140    194   
    mut builder: crate::input::malformed_long_input::Builder,
  141    195   
) -> ::std::result::Result<
  142    196   
    crate::input::malformed_long_input::Builder,
  143    197   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  144    198   
> {
         199  +
    /* JsonParserGenerator.kt:153 */
  145    200   
    let mut tokens_owned =
  146    201   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  147    202   
            .peekable();
  148    203   
    let tokens = &mut tokens_owned;
  149    204   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         205  +
    /* JsonParserGenerator.kt:684 */
  150    206   
    loop {
         207  +
        /* JsonParserGenerator.kt:685 */
  151    208   
        match tokens.next().transpose()? {
         209  +
            /* JsonParserGenerator.kt:686 */
  152    210   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  153    211   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         212  +
                /* JsonParserGenerator.kt:260 */
  154    213   
                match key.to_unescaped()?.as_ref() {
         214  +
                    /* JsonParserGenerator.kt:262 */
  155    215   
                    "longInBody" => {
         216  +
                        /* JsonParserGenerator.kt:272 */
  156    217   
                        builder = builder.set_long_in_body(
         218  +
                            /* JsonParserGenerator.kt:365 */
  157    219   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  158    220   
                                tokens.next(),
  159    221   
                            )?
  160    222   
                            .map(i64::try_from)
  161         -
                            .transpose()?,
         223  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  162    224   
                        );
         225  +
                        /* JsonParserGenerator.kt:262 */
  163    226   
                    }
  164         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         227  +
                    /* JsonParserGenerator.kt:290 */
         228  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  165    229   
                }
         230  +
                /* JsonParserGenerator.kt:686 */
  166    231   
            }
         232  +
            /* JsonParserGenerator.kt:695 */
  167    233   
            other => {
  168    234   
                return Err(
  169    235   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  170    236   
                        "expected object key or end object, found: {:?}",
  171    237   
                        other
  172    238   
                    )),
  173    239   
                )
         240  +
            } /* JsonParserGenerator.kt:685 */
  174    241   
        }
         242  +
        /* JsonParserGenerator.kt:684 */
  175    243   
    }
  176         -
    }
         244  +
    /* JsonParserGenerator.kt:250 */
  177    245   
    if tokens.next().is_some() {
         246  +
        /* JsonParserGenerator.kt:251 */
  178    247   
        return Err(
  179    248   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  180    249   
                "found more JSON tokens after completing parsing",
  181    250   
            ),
  182    251   
        );
         252  +
        /* JsonParserGenerator.kt:250 */
  183    253   
    }
         254  +
    /* JsonParserGenerator.kt:163 */
  184    255   
    Ok(builder)
         256  +
    /* JsonParserGenerator.kt:148 */
  185    257   
}

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

@@ -1,1 +36,49 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:153 */
    2      3   
pub(crate) fn de_long_in_header_header(
    3      4   
    header_map: &::aws_smithy_runtime_api::http::Headers,
    4      5   
) -> ::std::result::Result<::std::option::Option<i64>, ::aws_smithy_http::header::ParseError> {
           6  +
    /* HttpBindingGenerator.kt:160 */
    5      7   
    let headers = header_map.get_all("longInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i64>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    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:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   18     24   
pub fn de_long_in_path(
   19     25   
    value: &str,
   20     26   
) -> std::result::Result<
   21     27   
    i64,
   22     28   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   23     29   
> {
          30  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   28     38   
pub fn de_long_in_query(
   29     39   
    value: &str,
   30     40   
) -> std::result::Result<
   31     41   
    ::std::option::Option<i64>,
   32     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
   33     43   
> {
          44  +
    /* ServerHttpBoundProtocolGenerator.kt:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   36     49   
}

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

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

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

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

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

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

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:153 */
    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:160 */
    5      7   
    let headers = header_map.get_all("shortInHeader");
           8  +
    /* HttpBindingGenerator.kt:404 */
    6      9   
    let var_1 = ::aws_smithy_http::header::read_many_primitive::<i16>(headers)?;
          10  +
    /* HttpBindingGenerator.kt:468 */
    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:153 */
   16     21   
}
   17     22   
          23  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   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:1347 */
   24     31   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          32  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   25     33   
    Ok(value)
          34  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   26     35   
}
   27     36   
          37  +
/* ServerHttpBoundProtocolGenerator.kt:1292 */
   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:1347 */
   34     45   
    let value = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(value)?;
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:1357 */
   35     47   
    Ok(Some(value))
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:1292 */
   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:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_malformed_string_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::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:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::malformed_string_input::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:794 */
   22     30   
        if let Some(value) =
   23     31   
            crate::protocol_serde::shape_malformed_string_input::de_blob_header(&headers)?
   24     32   
        {
   25     33   
            input = input.set_blob(Some(value))
   26     34   
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   27     36   
        input.build()
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   28     38   
    })
          39  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   29     40   
}
   30     41   
          42  +
/* RustType.kt:516 */
   31     43   
#[allow(clippy::unnecessary_wraps)]
          44  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   32     45   
pub fn ser_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:433 */
   38     52   
    Ok({
          53  +
        /* RustType.kt:516 */
   39     54   
        #[allow(unused_mut)]
          55  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   40     56   
        let mut builder = ::http::Response::builder();
          57  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   41     58   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   42     59   
            builder,
   43     60   
            ::http::header::CONTENT_TYPE,
   44     61   
            "application/json",
   45     62   
        );
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   46     64   
        let http_status: u16 = 200;
   47     65   
        builder = builder.status(http_status);
   48         -
        let payload = "";
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          67  +
        let payload =
          68  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   49     71   
        let content_length = payload.len();
   50     72   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   51     73   
            builder,
   52     74   
            ::http::header::CONTENT_LENGTH,
   53     75   
            content_length,
   54     76   
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   55     78   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   56     80   
        builder.body(body)?
          81  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   57     82   
    })
          83  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   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:153 */
    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:160 */
    8     10   
    let headers = header_map.get_all("amz-media-typed-header");
          11  +
    /* HttpBindingGenerator.kt:409 */
    9     12   
    let var_1: Vec<::std::string::String> = ::aws_smithy_http::header::read_many_from_str(headers)?;
          13  +
    /* HttpBindingGenerator.kt:414 */
   10     14   
    let var_1: std::result::Result<Vec<_>, _> = var_1
   11     15   
        .iter()
   12     16   
        .map(|s| {
   13     17   
            ::aws_smithy_types::base64::decode(s)
   14     18   
                .map_err(|_| ::aws_smithy_http::header::ParseError::new("failed to decode base64"))
   15     19   
                .and_then(|bytes| {
   16     20   
                    String::from_utf8(bytes).map_err(|_| {
   17     21   
                        ::aws_smithy_http::header::ParseError::new(
   18     22   
                            "base64 encoded data was not valid utf-8",
   19     23   
                        )
   20     24   
                    })
   21     25   
                })
   22     26   
        })
   23     27   
        .collect();
          28  +
    /* HttpBindingGenerator.kt:425 */
   24     29   
    let var_1 = var_1?;
          30  +
    /* HttpBindingGenerator.kt:468 */
   25     31   
    if var_1.len() > 1 {
   26     32   
        Err(::aws_smithy_http::header::ParseError::new(format!(
   27     33   
            "expected one item but found {}",
   28     34   
            var_1.len()
   29     35   
        )))
   30     36   
    } else {
   31     37   
        let mut var_1 = var_1;
   32     38   
        Ok(var_1.pop())
   33     39   
    }
          40  +
    /* HttpBindingGenerator.kt:153 */
   34     41   
}

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

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

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

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

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

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