Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

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

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

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

@@ -0,1 +0,82 @@
           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_no_input_and_no_output_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::NoInputAndNoOutputInput,
           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::no_input_and_no_output_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:873 */
          30  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          31  +
            &headers, None,
          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_no_input_and_no_output_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::NoInputAndNoOutputOutput,
          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  +
}

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

@@ -0,1 +0,82 @@
           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_no_input_and_output_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::NoInputAndOutputInput,
           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::no_input_and_output_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:873 */
          30  +
        ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          31  +
            &headers, None,
          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_no_input_and_output_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::NoInputAndOutputOutput,
          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:235 */crate::protocol_serde::shape_no_input_and_output_output::ser_no_input_and_output_output_output_output(&output)?
          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  +
}

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

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

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

@@ -0,1 +0,180 @@
           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_null_and_empty_headers_client_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::NullAndEmptyHeadersClientInput,
           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::null_and_empty_headers_client_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_null_and_empty_headers_client_input::de_a_header(&headers)?
          32  +
        {
          33  +
            input = input.set_a(Some(value))
          34  +
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          36  +
        if let Some(value) =
          37  +
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_b_header(&headers)?
          38  +
        {
          39  +
            input = input.set_b(Some(value))
          40  +
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          42  +
        if let Some(value) =
          43  +
            crate::protocol_serde::shape_null_and_empty_headers_client_input::de_c_header(&headers)?
          44  +
        {
          45  +
            input = input.set_c(Some(value))
          46  +
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          48  +
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          50  +
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          52  +
}
          53  +
          54  +
/* RustType.kt:534 */
          55  +
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          57  +
pub fn ser_null_and_empty_headers_client_http_response(
          58  +
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersClientOutput,
          59  +
) -> std::result::Result<
          60  +
    ::aws_smithy_legacy_http_server::response::Response,
          61  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          62  +
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          64  +
    Ok({
          65  +
        /* RustType.kt:534 */
          66  +
        #[allow(unused_mut)]
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          68  +
        let mut builder = ::http::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          70  +
        builder = crate::protocol_serde::shape_null_and_empty_headers_client::ser_null_and_empty_headers_client_headers(&output, builder)?;
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          72  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          73  +
            builder,
          74  +
            ::http::header::CONTENT_TYPE,
          75  +
            "application/json",
          76  +
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          78  +
        let http_status: u16 = 200;
          79  +
        builder = builder.status(http_status);
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          81  +
        let payload =
          82  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_null_and_empty_headers_client_output::ser_null_and_empty_headers_client_output_output_output(&output)?
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          85  +
        let content_length = payload.len();
          86  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          87  +
            builder,
          88  +
            ::http::header::CONTENT_LENGTH,
          89  +
            content_length,
          90  +
        );
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          92  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          94  +
        builder.body(body)?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          96  +
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          98  +
}
          99  +
         100  +
/* HttpBindingGenerator.kt:565 */
         101  +
pub fn ser_null_and_empty_headers_client_headers(
         102  +
    input: &crate::output::NullAndEmptyHeadersClientOutput,
         103  +
    mut builder: ::http::response::Builder,
         104  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         105  +
{
         106  +
    /* HttpBindingGenerator.kt:615 */
         107  +
    if let ::std::option::Option::Some(inner_1) = &input.a {
         108  +
        /* HttpBindingGenerator.kt:727 */
         109  +
        let formatted_2 = inner_1.as_str();
         110  +
        /* HttpBindingGenerator.kt:728 */
         111  +
        if !formatted_2.is_empty() {
         112  +
            /* HttpBindingGenerator.kt:729 */
         113  +
            let header_value = formatted_2;
         114  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         115  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         116  +
                    "a",
         117  +
                    format!(
         118  +
                        "`{}` cannot be used as a header value: {}",
         119  +
                        &header_value, err
         120  +
                    ),
         121  +
                )
         122  +
            })?;
         123  +
            builder = builder.header("X-A", header_value);
         124  +
            /* HttpBindingGenerator.kt:728 */
         125  +
        }
         126  +
        /* HttpBindingGenerator.kt:615 */
         127  +
    }
         128  +
    /* HttpBindingGenerator.kt:615 */
         129  +
    if let ::std::option::Option::Some(inner_3) = &input.b {
         130  +
        /* HttpBindingGenerator.kt:727 */
         131  +
        let formatted_4 = inner_3.as_str();
         132  +
        /* HttpBindingGenerator.kt:728 */
         133  +
        if !formatted_4.is_empty() {
         134  +
            /* HttpBindingGenerator.kt:729 */
         135  +
            let header_value = formatted_4;
         136  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         137  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         138  +
                    "b",
         139  +
                    format!(
         140  +
                        "`{}` cannot be used as a header value: {}",
         141  +
                        &header_value, err
         142  +
                    ),
         143  +
                )
         144  +
            })?;
         145  +
            builder = builder.header("X-B", header_value);
         146  +
            /* HttpBindingGenerator.kt:728 */
         147  +
        }
         148  +
        /* HttpBindingGenerator.kt:615 */
         149  +
    }
         150  +
    /* HttpBindingGenerator.kt:615 */
         151  +
    if let ::std::option::Option::Some(inner_5) = &input.c {
         152  +
        /* HttpBindingGenerator.kt:669 */
         153  +
        for inner_6 in inner_5 {
         154  +
            /* HttpBindingGenerator.kt:727 */
         155  +
            let formatted_7 =
         156  +
                ::aws_smithy_legacy_http::header::quote_header_value(inner_6.as_str());
         157  +
            /* HttpBindingGenerator.kt:728 */
         158  +
            if !formatted_7.is_empty() {
         159  +
                /* HttpBindingGenerator.kt:729 */
         160  +
                let header_value = formatted_7;
         161  +
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         162  +
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
         163  +
                        "c",
         164  +
                        format!(
         165  +
                            "`{}` cannot be used as a header value: {}",
         166  +
                            &header_value, err
         167  +
                        ),
         168  +
                    )
         169  +
                })?;
         170  +
                builder = builder.header("X-C", header_value);
         171  +
                /* HttpBindingGenerator.kt:728 */
         172  +
            }
         173  +
            /* HttpBindingGenerator.kt:669 */
         174  +
        }
         175  +
        /* HttpBindingGenerator.kt:615 */
         176  +
    }
         177  +
    /* HttpBindingGenerator.kt:578 */
         178  +
    Ok(builder)
         179  +
    /* HttpBindingGenerator.kt:565 */
         180  +
}

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

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

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

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

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

@@ -0,1 +0,180 @@
           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_null_and_empty_headers_server_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::NullAndEmptyHeadersServerInput,
           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::null_and_empty_headers_server_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_null_and_empty_headers_server_input::de_a_header(&headers)?
          32  +
        {
          33  +
            input = input.set_a(Some(value))
          34  +
        }
          35  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          36  +
        if let Some(value) =
          37  +
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_b_header(&headers)?
          38  +
        {
          39  +
            input = input.set_b(Some(value))
          40  +
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          42  +
        if let Some(value) =
          43  +
            crate::protocol_serde::shape_null_and_empty_headers_server_input::de_c_header(&headers)?
          44  +
        {
          45  +
            input = input.set_c(Some(value))
          46  +
        }
          47  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          48  +
        input.build()
          49  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          50  +
    })
          51  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          52  +
}
          53  +
          54  +
/* RustType.kt:534 */
          55  +
#[allow(clippy::unnecessary_wraps)]
          56  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          57  +
pub fn ser_null_and_empty_headers_server_http_response(
          58  +
    #[allow(unused_variables)] output: crate::output::NullAndEmptyHeadersServerOutput,
          59  +
) -> std::result::Result<
          60  +
    ::aws_smithy_legacy_http_server::response::Response,
          61  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          62  +
> {
          63  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          64  +
    Ok({
          65  +
        /* RustType.kt:534 */
          66  +
        #[allow(unused_mut)]
          67  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          68  +
        let mut builder = ::http::Response::builder();
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          70  +
        builder = crate::protocol_serde::shape_null_and_empty_headers_server::ser_null_and_empty_headers_server_headers(&output, builder)?;
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          72  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          73  +
            builder,
          74  +
            ::http::header::CONTENT_TYPE,
          75  +
            "application/json",
          76  +
        );
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          78  +
        let http_status: u16 = 200;
          79  +
        builder = builder.status(http_status);
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          81  +
        let payload =
          82  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_null_and_empty_headers_server_output::ser_null_and_empty_headers_server_output_output_output(&output)?
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          85  +
        let content_length = payload.len();
          86  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          87  +
            builder,
          88  +
            ::http::header::CONTENT_LENGTH,
          89  +
            content_length,
          90  +
        );
          91  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          92  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          93  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          94  +
        builder.body(body)?
          95  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          96  +
    })
          97  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          98  +
}
          99  +
         100  +
/* HttpBindingGenerator.kt:565 */
         101  +
pub fn ser_null_and_empty_headers_server_headers(
         102  +
    input: &crate::output::NullAndEmptyHeadersServerOutput,
         103  +
    mut builder: ::http::response::Builder,
         104  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         105  +
{
         106  +
    /* HttpBindingGenerator.kt:615 */
         107  +
    if let ::std::option::Option::Some(inner_1) = &input.a {
         108  +
        /* HttpBindingGenerator.kt:727 */
         109  +
        let formatted_2 = inner_1.as_str();
         110  +
        /* HttpBindingGenerator.kt:728 */
         111  +
        if !formatted_2.is_empty() {
         112  +
            /* HttpBindingGenerator.kt:729 */
         113  +
            let header_value = formatted_2;
         114  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         115  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         116  +
                    "a",
         117  +
                    format!(
         118  +
                        "`{}` cannot be used as a header value: {}",
         119  +
                        &header_value, err
         120  +
                    ),
         121  +
                )
         122  +
            })?;
         123  +
            builder = builder.header("X-A", header_value);
         124  +
            /* HttpBindingGenerator.kt:728 */
         125  +
        }
         126  +
        /* HttpBindingGenerator.kt:615 */
         127  +
    }
         128  +
    /* HttpBindingGenerator.kt:615 */
         129  +
    if let ::std::option::Option::Some(inner_3) = &input.b {
         130  +
        /* HttpBindingGenerator.kt:727 */
         131  +
        let formatted_4 = inner_3.as_str();
         132  +
        /* HttpBindingGenerator.kt:728 */
         133  +
        if !formatted_4.is_empty() {
         134  +
            /* HttpBindingGenerator.kt:729 */
         135  +
            let header_value = formatted_4;
         136  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         137  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         138  +
                    "b",
         139  +
                    format!(
         140  +
                        "`{}` cannot be used as a header value: {}",
         141  +
                        &header_value, err
         142  +
                    ),
         143  +
                )
         144  +
            })?;
         145  +
            builder = builder.header("X-B", header_value);
         146  +
            /* HttpBindingGenerator.kt:728 */
         147  +
        }
         148  +
        /* HttpBindingGenerator.kt:615 */
         149  +
    }
         150  +
    /* HttpBindingGenerator.kt:615 */
         151  +
    if let ::std::option::Option::Some(inner_5) = &input.c {
         152  +
        /* HttpBindingGenerator.kt:669 */
         153  +
        for inner_6 in inner_5 {
         154  +
            /* HttpBindingGenerator.kt:727 */
         155  +
            let formatted_7 =
         156  +
                ::aws_smithy_legacy_http::header::quote_header_value(inner_6.as_str());
         157  +
            /* HttpBindingGenerator.kt:728 */
         158  +
            if !formatted_7.is_empty() {
         159  +
                /* HttpBindingGenerator.kt:729 */
         160  +
                let header_value = formatted_7;
         161  +
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         162  +
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
         163  +
                        "c",
         164  +
                        format!(
         165  +
                            "`{}` cannot be used as a header value: {}",
         166  +
                            &header_value, err
         167  +
                        ),
         168  +
                    )
         169  +
                })?;
         170  +
                builder = builder.header("X-C", header_value);
         171  +
                /* HttpBindingGenerator.kt:728 */
         172  +
            }
         173  +
            /* HttpBindingGenerator.kt:669 */
         174  +
        }
         175  +
        /* HttpBindingGenerator.kt:615 */
         176  +
    }
         177  +
    /* HttpBindingGenerator.kt:578 */
         178  +
    Ok(builder)
         179  +
    /* HttpBindingGenerator.kt:565 */
         180  +
}

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

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

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

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

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

@@ -0,1 +0,103 @@
           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_omits_null_serializes_empty_string_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::OmitsNullSerializesEmptyStringInput,
           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::omits_null_serializes_empty_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:1221 */
          30  +
        let query_string = uri.query().unwrap_or("");
          31  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
          33  +
        let mut empty_string_seen = false;
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:1247 */
          35  +
        let mut null_value_seen = false;
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          37  +
        for (k, v) in pairs {
          38  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          39  +
            if !empty_string_seen && k == "Empty" {
          40  +
                input = input.set_empty_string(
          41  +
                    crate::protocol_serde::shape_omits_null_serializes_empty_string_input::de_empty_string(&v)?
          42  +
                );
          43  +
                empty_string_seen = true;
          44  +
            }
          45  +
            /* ServerHttpBoundProtocolGenerator.kt:1257 */
          46  +
            if !null_value_seen && k == "Null" {
          47  +
                input = input.set_null_value(
          48  +
                    crate::protocol_serde::shape_omits_null_serializes_empty_string_input::de_null_value(&v)?
          49  +
                );
          50  +
                null_value_seen = true;
          51  +
            }
          52  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
          53  +
        }
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          55  +
        input.build()
          56  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          57  +
    })
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          59  +
}
          60  +
          61  +
/* RustType.kt:534 */
          62  +
#[allow(clippy::unnecessary_wraps)]
          63  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          64  +
pub fn ser_omits_null_serializes_empty_string_http_response(
          65  +
    #[allow(unused_variables)] output: crate::output::OmitsNullSerializesEmptyStringOutput,
          66  +
) -> std::result::Result<
          67  +
    ::aws_smithy_legacy_http_server::response::Response,
          68  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          69  +
> {
          70  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          71  +
    Ok({
          72  +
        /* RustType.kt:534 */
          73  +
        #[allow(unused_mut)]
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          75  +
        let mut builder = ::http::Response::builder();
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          77  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          78  +
            builder,
          79  +
            ::http::header::CONTENT_TYPE,
          80  +
            "application/json",
          81  +
        );
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          83  +
        let http_status: u16 = 200;
          84  +
        builder = builder.status(http_status);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          86  +
        let payload =
          87  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          90  +
        let content_length = payload.len();
          91  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          92  +
            builder,
          93  +
            ::http::header::CONTENT_LENGTH,
          94  +
            content_length,
          95  +
        );
          96  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          97  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          98  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          99  +
        builder.body(body)?
         100  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         101  +
    })
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         103  +
}

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

@@ -0,1 +0,28 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
           3  +
pub fn de_empty_string(
           4  +
    value: &str,
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<::std::string::String>,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
> {
           9  +
    /* ServerHttpBoundProtocolGenerator.kt:1470 */
          10  +
    let value = value.to_owned();
          11  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          12  +
    Ok(Some(value))
          13  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          14  +
}
          15  +
          16  +
/* ServerHttpBoundProtocolGenerator.kt:1453 */
          17  +
pub fn de_null_value(
          18  +
    value: &str,
          19  +
) -> std::result::Result<
          20  +
    ::std::option::Option<::std::string::String>,
          21  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
          22  +
> {
          23  +
    /* ServerHttpBoundProtocolGenerator.kt:1470 */
          24  +
    let value = value.to_owned();
          25  +
    /* ServerHttpBoundProtocolGenerator.kt:1525 */
          26  +
    Ok(Some(value))
          27  +
    /* ServerHttpBoundProtocolGenerator.kt:1453 */
          28  +
}

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

@@ -0,1 +0,295 @@
           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_omits_serializing_empty_lists_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::OmitsSerializingEmptyListsInput,
           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::omits_serializing_empty_lists_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:1221 */
          30  +
        let query_string = uri.query().unwrap_or("");
          31  +
        let pairs = ::form_urlencoded::parse(query_string.as_bytes());
          32  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          33  +
        let mut query_boolean_list = Vec::new();
          34  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          35  +
        let mut query_double_list = Vec::new();
          36  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          37  +
        let mut query_enum_list = Vec::new();
          38  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          39  +
        let mut query_integer_enum_list = Vec::new();
          40  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          41  +
        let mut query_integer_list = Vec::new();
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          43  +
        let mut query_string_list = Vec::new();
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:1250 */
          45  +
        let mut query_timestamp_list = Vec::new();
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:1253 */
          47  +
        for (k, v) in pairs {
          48  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          49  +
            if k == "BooleanList" {
          50  +
                /* ServerHttpBoundProtocolGenerator.kt:1318 */
          51  +
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          52  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          53  +
                query_boolean_list.push(v);
          54  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          55  +
            }
          56  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          57  +
            else if k == "DoubleList" {
          58  +
                /* ServerHttpBoundProtocolGenerator.kt:1318 */
          59  +
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          60  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          61  +
                query_double_list.push(v);
          62  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          63  +
            }
          64  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          65  +
            else if k == "EnumList" {
          66  +
                /* ServerHttpBoundProtocolGenerator.kt:1282 */
          67  +
                let v = v.into_owned();
          68  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          69  +
                query_enum_list.push(v);
          70  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          71  +
            }
          72  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          73  +
            else if k == "IntegerEnumList" {
          74  +
                /* ServerHttpBoundProtocolGenerator.kt:1318 */
          75  +
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          76  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          77  +
                query_integer_enum_list.push(v);
          78  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          79  +
            }
          80  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          81  +
            else if k == "IntegerList" {
          82  +
                /* ServerHttpBoundProtocolGenerator.kt:1318 */
          83  +
                let v = <_ as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(&v)?;
          84  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          85  +
                query_integer_list.push(v);
          86  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          87  +
            }
          88  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          89  +
            else if k == "StringList" {
          90  +
                /* ServerHttpBoundProtocolGenerator.kt:1282 */
          91  +
                let v = v.into_owned();
          92  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
          93  +
                query_string_list.push(v);
          94  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          95  +
            }
          96  +
            /* ServerHttpBoundProtocolGenerator.kt:1270 */
          97  +
            else if k == "TimestampList" {
          98  +
                /* ServerHttpBoundProtocolGenerator.kt:1300 */
          99  +
                let v = ::aws_smithy_types::DateTime::from_str(&v, ::aws_smithy_types::date_time::Format::DateTime)?
         100  +
                /* ServerHttpBoundProtocolGenerator.kt:1314 */;
         101  +
                /* ServerHttpBoundProtocolGenerator.kt:1327 */
         102  +
                query_timestamp_list.push(v);
         103  +
                /* ServerHttpBoundProtocolGenerator.kt:1270 */
         104  +
            }
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:1253 */
         106  +
        }
         107  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         108  +
        if !query_boolean_list.is_empty() {
         109  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         110  +
            input = input.set_query_boolean_list(
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         112  +
                Some(
         113  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         114  +
                    query_boolean_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         115  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         116  +
            );
         117  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         118  +
        }
         119  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         120  +
        if !query_double_list.is_empty() {
         121  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         122  +
            input = input.set_query_double_list(
         123  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         124  +
                Some(
         125  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         126  +
                    query_double_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         127  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         128  +
            );
         129  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         130  +
        }
         131  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         132  +
        if !query_enum_list.is_empty() {
         133  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         134  +
            input = input.set_query_enum_list(
         135  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         136  +
                Some(
         137  +
                    /* ServerHttpBoundProtocolGenerator.kt:1397 */
         138  +
                    crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained(
         139  +
                        /* ServerHttpBoundProtocolGenerator.kt:1405 */
         140  +
                        query_enum_list, /* ServerHttpBoundProtocolGenerator.kt:1397 */
         141  +
                    ), /* ServerHttpBoundProtocolGenerator.kt:1396 */
         142  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         143  +
            );
         144  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         145  +
        }
         146  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         147  +
        if !query_integer_enum_list.is_empty() {
         148  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         149  +
            input = input.set_query_integer_enum_list(
         150  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         151  +
                Some(
         152  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         153  +
                    query_integer_enum_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         154  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         155  +
            );
         156  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         157  +
        }
         158  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         159  +
        if !query_integer_list.is_empty() {
         160  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         161  +
            input = input.set_query_integer_list(
         162  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         163  +
                Some(
         164  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         165  +
                    query_integer_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         166  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         167  +
            );
         168  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         169  +
        }
         170  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         171  +
        if !query_string_list.is_empty() {
         172  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         173  +
            input = input.set_query_string_list(
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         175  +
                Some(
         176  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         177  +
                    query_string_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         178  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         179  +
            );
         180  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         181  +
        }
         182  +
        /* ServerHttpBoundProtocolGenerator.kt:1389 */
         183  +
        if !query_timestamp_list.is_empty() {
         184  +
            /* ServerHttpBoundProtocolGenerator.kt:1390 */
         185  +
            input = input.set_query_timestamp_list(
         186  +
                /* ServerHttpBoundProtocolGenerator.kt:1396 */
         187  +
                Some(
         188  +
                    /* ServerHttpBoundProtocolGenerator.kt:1405 */
         189  +
                    query_timestamp_list, /* ServerHttpBoundProtocolGenerator.kt:1396 */
         190  +
                ), /* ServerHttpBoundProtocolGenerator.kt:1390 */
         191  +
            );
         192  +
            /* ServerHttpBoundProtocolGenerator.kt:1389 */
         193  +
        }
         194  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
         195  +
        input.build()?
         196  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
         197  +
    })
         198  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
         199  +
}
         200  +
         201  +
/* RustType.kt:534 */
         202  +
#[allow(clippy::unnecessary_wraps)]
         203  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
         204  +
pub fn ser_omits_serializing_empty_lists_http_response(
         205  +
    #[allow(unused_variables)] output: crate::output::OmitsSerializingEmptyListsOutput,
         206  +
) -> std::result::Result<
         207  +
    ::aws_smithy_legacy_http_server::response::Response,
         208  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         209  +
> {
         210  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
         211  +
    Ok({
         212  +
        /* RustType.kt:534 */
         213  +
        #[allow(unused_mut)]
         214  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
         215  +
        let mut builder = ::http::Response::builder();
         216  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
         217  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         218  +
            builder,
         219  +
            ::http::header::CONTENT_TYPE,
         220  +
            "application/json",
         221  +
        );
         222  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
         223  +
        let http_status: u16 = 200;
         224  +
        builder = builder.status(http_status);
         225  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
         226  +
        let payload =
         227  +
            /* HttpBoundProtocolPayloadGenerator.kt:233 */""
         228  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
         229  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
         230  +
        let content_length = payload.len();
         231  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         232  +
            builder,
         233  +
            ::http::header::CONTENT_LENGTH,
         234  +
            content_length,
         235  +
        );
         236  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
         237  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
         238  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
         239  +
        builder.body(body)?
         240  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
         241  +
    })
         242  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
         243  +
}
         244  +
         245  +
/* RustType.kt:534 */
         246  +
#[allow(clippy::unnecessary_wraps)]
         247  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
         248  +
pub fn ser_omits_serializing_empty_lists_http_error(
         249  +
    error: &crate::error::OmitsSerializingEmptyListsError,
         250  +
) -> std::result::Result<
         251  +
    ::aws_smithy_legacy_http_server::response::Response,
         252  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         253  +
> {
         254  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         255  +
    Ok({
         256  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         257  +
        match error {
         258  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         259  +
            crate::error::OmitsSerializingEmptyListsError::ValidationException(output) => {
         260  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         261  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         262  +
                /* RustType.kt:534 */
         263  +
                #[allow(unused_mut)]
         264  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         265  +
                let mut builder = ::http::Response::builder();
         266  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         267  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         268  +
                    builder,
         269  +
                    ::http::header::CONTENT_TYPE,
         270  +
                    "application/json",
         271  +
                );
         272  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         273  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         274  +
                    builder,
         275  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         276  +
                    "ValidationException",
         277  +
                );
         278  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         279  +
                let content_length = payload.len();
         280  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         281  +
                    builder,
         282  +
                    ::http::header::CONTENT_LENGTH,
         283  +
                    content_length,
         284  +
                );
         285  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         286  +
                builder
         287  +
                    .status(400)
         288  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         289  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         290  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         291  +
        }
         292  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         293  +
    })
         294  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         295  +
}