Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5

Files changed:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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