Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,31 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_http_checksum_required_output_output_output(
           4  +
    value: &crate::output::HttpChecksumRequiredOutput,
           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_http_checksum_required_output::ser_http_checksum_required_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_http_checksum_required_output_output(
          19  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    input: &crate::output::HttpChecksumRequiredOutput,
          21  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
          23  +
    if let Some(var_1) = &input.foo {
          24  +
        /* JsonSerializerGenerator.kt:423 */
          25  +
        object.key("foo").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
          27  +
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
          29  +
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
          31  +
}

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

@@ -0,1 +0,152 @@
           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_http_empty_prefix_headers_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpEmptyPrefixHeadersInput,
           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::http_empty_prefix_headers_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_http_empty_prefix_headers_input::de_prefix_headers_prefix_header(&headers)? {
          31  +
                                input = input.set_prefix_headers(Some(value))
          32  +
                            }
          33  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          34  +
        if let Some(value) =
          35  +
            crate::protocol_serde::shape_http_empty_prefix_headers_input::de_specific_header_header(
          36  +
                &headers,
          37  +
            )?
          38  +
        {
          39  +
            input = input.set_specific_header(Some(value))
          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_http_empty_prefix_headers_http_response(
          52  +
    #[allow(unused_variables)] output: crate::output::HttpEmptyPrefixHeadersOutput,
          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:665 */
          64  +
        builder = crate::protocol_serde::shape_http_empty_prefix_headers::ser_http_empty_prefix_headers_headers(&output, builder)?;
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          66  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          67  +
            builder,
          68  +
            ::http::header::CONTENT_TYPE,
          69  +
            "application/json",
          70  +
        );
          71  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          72  +
        let http_status: u16 = 200;
          73  +
        builder = builder.status(http_status);
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          75  +
        let payload =
          76  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_http_empty_prefix_headers_output::ser_http_empty_prefix_headers_output_output_output(&output)?
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          79  +
        let content_length = payload.len();
          80  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          81  +
            builder,
          82  +
            ::http::header::CONTENT_LENGTH,
          83  +
            content_length,
          84  +
        );
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          86  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          88  +
        builder.body(body)?
          89  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          90  +
    })
          91  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          92  +
}
          93  +
          94  +
/* HttpBindingGenerator.kt:565 */
          95  +
pub fn ser_http_empty_prefix_headers_headers(
          96  +
    input: &crate::output::HttpEmptyPrefixHeadersOutput,
          97  +
    mut builder: ::http::response::Builder,
          98  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          99  +
{
         100  +
    /* HttpBindingGenerator.kt:615 */
         101  +
    if let ::std::option::Option::Some(inner_1) = &input.specific_header {
         102  +
        /* HttpBindingGenerator.kt:727 */
         103  +
        let formatted_2 = inner_1.as_str();
         104  +
        /* HttpBindingGenerator.kt:728 */
         105  +
        if !formatted_2.is_empty() {
         106  +
            /* HttpBindingGenerator.kt:729 */
         107  +
            let header_value = formatted_2;
         108  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         109  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         110  +
                    "specific_header",
         111  +
                    format!(
         112  +
                        "`{}` cannot be used as a header value: {}",
         113  +
                        &header_value, err
         114  +
                    ),
         115  +
                )
         116  +
            })?;
         117  +
            builder = builder.header("hello", header_value);
         118  +
            /* HttpBindingGenerator.kt:728 */
         119  +
        }
         120  +
        /* HttpBindingGenerator.kt:615 */
         121  +
    }
         122  +
    /* HttpBindingGenerator.kt:764 */
         123  +
    if let ::std::option::Option::Some(inner_3) = &input.prefix_headers {
         124  +
        /* HttpBindingGenerator.kt:764 */
         125  +
        {
         126  +
            /* HttpBindingGenerator.kt:770 */
         127  +
            for (k, v) in inner_3 {
         128  +
                use std::str::FromStr;
         129  +
                let header_name =
         130  +
                    ::http::HeaderName::from_str(&format!("{}{}", "", &k)).map_err(|err| {
         131  +
                        ::aws_smithy_types::error::operation::BuildError::invalid_field(
         132  +
                            "prefix_headers",
         133  +
                            format!("`{k}` cannot be used as a header name: {err}"),
         134  +
                        )
         135  +
                    })?;
         136  +
                let header_value = v.as_str();
         137  +
                let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         138  +
                    ::aws_smithy_types::error::operation::BuildError::invalid_field(
         139  +
                        "prefix_headers",
         140  +
                        format!("`{v}` cannot be used as a header value: {err}"),
         141  +
                    )
         142  +
                })?;
         143  +
                builder = builder.header(header_name, header_value);
         144  +
            }
         145  +
            /* HttpBindingGenerator.kt:764 */
         146  +
        }
         147  +
        /* HttpBindingGenerator.kt:764 */
         148  +
    }
         149  +
    /* HttpBindingGenerator.kt:578 */
         150  +
    Ok(builder)
         151  +
    /* HttpBindingGenerator.kt:565 */
         152  +
}

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

@@ -0,1 +0,47 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:190 */
           3  +
pub(crate) fn de_prefix_headers_prefix_header(
           4  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<
           7  +
        ::std::collections::HashMap<::std::string::String, ::std::string::String>,
           8  +
    >,
           9  +
    ::aws_smithy_legacy_http::header::ParseError,
          10  +
> {
          11  +
    /* HttpBindingGenerator.kt:196 */
          12  +
    let headers =
          13  +
        ::aws_smithy_legacy_http::header::headers_for_prefix(header_map.iter().map(|(k, _)| k), "");
          14  +
    let out: std::result::Result<_, _> = headers.map(|(key, header_name)| {
          15  +
                            let values = header_map.get_all(header_name);
          16  +
                            crate::protocol_serde::shape_http_empty_prefix_headers_input::de_prefix_headers_inner(values).map(|v| (key.to_string(), v.expect(
          17  +
                                "we have checked there is at least one value for this header name; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues"
          18  +
                            )))
          19  +
                        }).collect();
          20  +
    /* HttpBindingGenerator.kt:217 */
          21  +
    out.map(Some)
          22  +
    /* HttpBindingGenerator.kt:190 */
          23  +
}
          24  +
          25  +
/* HttpBindingGenerator.kt:159 */
          26  +
pub(crate) fn de_specific_header_header(
          27  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          28  +
) -> ::std::result::Result<
          29  +
    ::std::option::Option<::std::string::String>,
          30  +
    ::aws_smithy_legacy_http::header::ParseError,
          31  +
> {
          32  +
    /* HttpBindingGenerator.kt:166 */
          33  +
    let headers = header_map.get_all("hello");
          34  +
    /* HttpBindingGenerator.kt:398 */
          35  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          36  +
    /* HttpBindingGenerator.kt:159 */
          37  +
}
          38  +
          39  +
/* HttpBindingGenerator.kt:179 */
          40  +
pub fn de_prefix_headers_inner<'a>(
          41  +
    headers: impl ::std::iter::Iterator<Item = &'a str>,
          42  +
) -> std::result::Result<Option<::std::string::String>, ::aws_smithy_legacy_http::header::ParseError>
          43  +
{
          44  +
    /* HttpBindingGenerator.kt:398 */
          45  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          46  +
    /* HttpBindingGenerator.kt:179 */
          47  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_http_empty_prefix_headers_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_http_empty_prefix_headers_output_output_output(
           4  +
    value: &crate::output::HttpEmptyPrefixHeadersOutput,
           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_http_empty_prefix_headers_output::ser_http_empty_prefix_headers_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_http_empty_prefix_headers_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::HttpEmptyPrefixHeadersOutput,
          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_http_enum_payload.rs

@@ -0,1 +0,143 @@
           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_http_enum_payload_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpEnumPayloadInput,
           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::http_enum_payload_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  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
            if !bytes.is_empty() {
          33  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          34  +
                    &headers,
          35  +
                    Some("text/plain"),
          36  +
                )?;
          37  +
            }
          38  +
            crate::protocol_serde::shape_http_enum_payload_input::de_payload_payload(&bytes)?
          39  +
        } {
          40  +
            input = input.set_payload(Some(value))
          41  +
        }
          42  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          43  +
        input.build()?
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          45  +
    })
          46  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          47  +
}
          48  +
          49  +
/* RustType.kt:534 */
          50  +
#[allow(clippy::unnecessary_wraps)]
          51  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          52  +
pub fn ser_http_enum_payload_http_response(
          53  +
    #[allow(unused_variables)] output: crate::output::HttpEnumPayloadOutput,
          54  +
) -> std::result::Result<
          55  +
    ::aws_smithy_legacy_http_server::response::Response,
          56  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          57  +
> {
          58  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          59  +
    Ok({
          60  +
        /* RustType.kt:534 */
          61  +
        #[allow(unused_mut)]
          62  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          63  +
        let mut builder = ::http::Response::builder();
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          65  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          66  +
            builder,
          67  +
            ::http::header::CONTENT_TYPE,
          68  +
            "text/plain",
          69  +
        );
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          71  +
        let http_status: u16 = 200;
          72  +
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          74  +
        let payload =
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:348 */crate::protocol_serde::shape_http_enum_payload_output::ser_payload_http_payload( output.payload)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          78  +
        let content_length = payload.len();
          79  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
            builder,
          81  +
            ::http::header::CONTENT_LENGTH,
          82  +
            content_length,
          83  +
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          85  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          87  +
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          89  +
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          91  +
}
          92  +
          93  +
/* RustType.kt:534 */
          94  +
#[allow(clippy::unnecessary_wraps)]
          95  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          96  +
pub fn ser_http_enum_payload_http_error(
          97  +
    error: &crate::error::HttpEnumPayloadError,
          98  +
) -> std::result::Result<
          99  +
    ::aws_smithy_legacy_http_server::response::Response,
         100  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
         101  +
> {
         102  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
         103  +
    Ok({
         104  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         105  +
        match error {
         106  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         107  +
            crate::error::HttpEnumPayloadError::ValidationException(output) => {
         108  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         109  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         110  +
                /* RustType.kt:534 */
         111  +
                #[allow(unused_mut)]
         112  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         113  +
                let mut builder = ::http::Response::builder();
         114  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         115  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         116  +
                    builder,
         117  +
                    ::http::header::CONTENT_TYPE,
         118  +
                    "text/plain",
         119  +
                );
         120  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         121  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         122  +
                    builder,
         123  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         124  +
                    "ValidationException",
         125  +
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         127  +
                let content_length = payload.len();
         128  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         129  +
                    builder,
         130  +
                    ::http::header::CONTENT_LENGTH,
         131  +
                    content_length,
         132  +
                );
         133  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         134  +
                builder
         135  +
                    .status(400)
         136  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         137  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         138  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         139  +
        }
         140  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         141  +
    })
         142  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         143  +
}

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

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_payload_payload(
           4  +
    body: &[u8],
           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  +
    /* HttpBindingGenerator.kt:342 */
          10  +
    (!body.is_empty())
          11  +
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:355 */
          13  +
            let body_str = std::str::from_utf8(body)?;
          14  +
            /* HttpBindingGenerator.kt:362 */
          15  +
            Ok(::std::string::String::from(body_str))
          16  +
            /* HttpBindingGenerator.kt:342 */
          17  +
        })
          18  +
        .transpose()
          19  +
    /* HttpBindingGenerator.kt:254 */
          20  +
}

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

@@ -0,1 +0,22 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_payload_http_payload(
           4  +
    payload: ::std::option::Option<crate::model::StringEnum>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:330 */
          12  +
                Vec::new(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:361 */
          19  +
        payload.as_str().as_bytes().to_vec(), /* HttpBoundProtocolPayloadGenerator.kt:343 */
          20  +
    )
          21  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          22  +
}

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

@@ -0,1 +0,124 @@
           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_http_payload_traits_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPayloadTraitsInput,
           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::http_payload_traits_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  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
          33  +
            crate::protocol_serde::shape_http_payload_traits_input::de_blob_payload(&bytes)?
          34  +
        } {
          35  +
            input = input.set_blob(Some(value))
          36  +
        }
          37  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          38  +
        if let Some(value) =
          39  +
            crate::protocol_serde::shape_http_payload_traits_input::de_foo_header(&headers)?
          40  +
        {
          41  +
            input = input.set_foo(Some(value))
          42  +
        }
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          44  +
        input.build()
          45  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          46  +
    })
          47  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          48  +
}
          49  +
          50  +
/* RustType.kt:534 */
          51  +
#[allow(clippy::unnecessary_wraps)]
          52  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          53  +
pub fn ser_http_payload_traits_http_response(
          54  +
    #[allow(unused_variables)] output: crate::output::HttpPayloadTraitsOutput,
          55  +
) -> std::result::Result<
          56  +
    ::aws_smithy_legacy_http_server::response::Response,
          57  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          58  +
> {
          59  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          60  +
    Ok({
          61  +
        /* RustType.kt:534 */
          62  +
        #[allow(unused_mut)]
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          64  +
        let mut builder = ::http::Response::builder();
          65  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          66  +
        builder =
          67  +
            crate::protocol_serde::shape_http_payload_traits::ser_http_payload_traits_headers(
          68  +
                &output, builder,
          69  +
            )?;
          70  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          71  +
        let http_status: u16 = 200;
          72  +
        builder = builder.status(http_status);
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          74  +
        let payload =
          75  +
            /* HttpBoundProtocolPayloadGenerator.kt:348 */crate::protocol_serde::shape_http_payload_traits_output::ser_blob_http_payload( output.blob)?
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          77  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          78  +
        let content_length = payload.len();
          79  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
            builder,
          81  +
            ::http::header::CONTENT_LENGTH,
          82  +
            content_length,
          83  +
        );
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          85  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          87  +
        builder.body(body)?
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          89  +
    })
          90  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          91  +
}
          92  +
          93  +
/* HttpBindingGenerator.kt:565 */
          94  +
pub fn ser_http_payload_traits_headers(
          95  +
    input: &crate::output::HttpPayloadTraitsOutput,
          96  +
    mut builder: ::http::response::Builder,
          97  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
          98  +
{
          99  +
    /* HttpBindingGenerator.kt:615 */
         100  +
    if let ::std::option::Option::Some(inner_1) = &input.foo {
         101  +
        /* HttpBindingGenerator.kt:727 */
         102  +
        let formatted_2 = inner_1.as_str();
         103  +
        /* HttpBindingGenerator.kt:728 */
         104  +
        if !formatted_2.is_empty() {
         105  +
            /* HttpBindingGenerator.kt:729 */
         106  +
            let header_value = formatted_2;
         107  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         108  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         109  +
                    "foo",
         110  +
                    format!(
         111  +
                        "`{}` cannot be used as a header value: {}",
         112  +
                        &header_value, err
         113  +
                    ),
         114  +
                )
         115  +
            })?;
         116  +
            builder = builder.header("X-Foo", header_value);
         117  +
            /* HttpBindingGenerator.kt:728 */
         118  +
        }
         119  +
        /* HttpBindingGenerator.kt:615 */
         120  +
    }
         121  +
    /* HttpBindingGenerator.kt:578 */
         122  +
    Ok(builder)
         123  +
    /* HttpBindingGenerator.kt:565 */
         124  +
}

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

@@ -0,1 +0,32 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_blob_payload(
           4  +
    body: &[u8],
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<::aws_smithy_types::Blob>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
          10  +
    (!body.is_empty())
          11  +
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:372 */
          13  +
            Ok(::aws_smithy_types::Blob::new(body))
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
          16  +
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
          18  +
}
          19  +
          20  +
/* HttpBindingGenerator.kt:159 */
          21  +
pub(crate) fn de_foo_header(
          22  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          23  +
) -> ::std::result::Result<
          24  +
    ::std::option::Option<::std::string::String>,
          25  +
    ::aws_smithy_legacy_http::header::ParseError,
          26  +
> {
          27  +
    /* HttpBindingGenerator.kt:166 */
          28  +
    let headers = header_map.get_all("X-Foo");
          29  +
    /* HttpBindingGenerator.kt:398 */
          30  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          31  +
    /* HttpBindingGenerator.kt:159 */
          32  +
}

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

@@ -0,1 +0,22 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_blob_http_payload(
           4  +
    payload: ::std::option::Option<::aws_smithy_types::Blob>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:330 */
          12  +
                Vec::new(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:375 */
          19  +
        payload.into_inner(), /* HttpBoundProtocolPayloadGenerator.kt:343 */
          20  +
    )
          21  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          22  +
}

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

@@ -0,1 +0,136 @@
           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_http_payload_traits_with_media_type_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPayloadTraitsWithMediaTypeInput,
           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::http_payload_traits_with_media_type_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  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
            if !bytes.is_empty() {
          33  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          34  +
                    &headers,
          35  +
                    Some("text/plain"),
          36  +
                )?;
          37  +
            }
          38  +
            crate::protocol_serde::shape_http_payload_traits_with_media_type_input::de_blob_payload(
          39  +
                &bytes,
          40  +
            )?
          41  +
        } {
          42  +
            input = input.set_blob(Some(value))
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:856 */
          45  +
        if let Some(value) =
          46  +
            crate::protocol_serde::shape_http_payload_traits_with_media_type_input::de_foo_header(
          47  +
                &headers,
          48  +
            )?
          49  +
        {
          50  +
            input = input.set_foo(Some(value))
          51  +
        }
          52  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          53  +
        input.build()
          54  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          55  +
    })
          56  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          57  +
}
          58  +
          59  +
/* RustType.kt:534 */
          60  +
#[allow(clippy::unnecessary_wraps)]
          61  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          62  +
pub fn ser_http_payload_traits_with_media_type_http_response(
          63  +
    #[allow(unused_variables)] output: crate::output::HttpPayloadTraitsWithMediaTypeOutput,
          64  +
) -> std::result::Result<
          65  +
    ::aws_smithy_legacy_http_server::response::Response,
          66  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          67  +
> {
          68  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          69  +
    Ok({
          70  +
        /* RustType.kt:534 */
          71  +
        #[allow(unused_mut)]
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          73  +
        let mut builder = ::http::Response::builder();
          74  +
        /* ServerHttpBoundProtocolGenerator.kt:665 */
          75  +
        builder = crate::protocol_serde::shape_http_payload_traits_with_media_type::ser_http_payload_traits_with_media_type_headers(&output, 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  +
            "text/plain",
          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:348 */crate::protocol_serde::shape_http_payload_traits_with_media_type_output::ser_blob_http_payload( output.blob)?
          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  +
}
         104  +
         105  +
/* HttpBindingGenerator.kt:565 */
         106  +
pub fn ser_http_payload_traits_with_media_type_headers(
         107  +
    input: &crate::output::HttpPayloadTraitsWithMediaTypeOutput,
         108  +
    mut builder: ::http::response::Builder,
         109  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         110  +
{
         111  +
    /* HttpBindingGenerator.kt:615 */
         112  +
    if let ::std::option::Option::Some(inner_1) = &input.foo {
         113  +
        /* HttpBindingGenerator.kt:727 */
         114  +
        let formatted_2 = inner_1.as_str();
         115  +
        /* HttpBindingGenerator.kt:728 */
         116  +
        if !formatted_2.is_empty() {
         117  +
            /* HttpBindingGenerator.kt:729 */
         118  +
            let header_value = formatted_2;
         119  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         120  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         121  +
                    "foo",
         122  +
                    format!(
         123  +
                        "`{}` cannot be used as a header value: {}",
         124  +
                        &header_value, err
         125  +
                    ),
         126  +
                )
         127  +
            })?;
         128  +
            builder = builder.header("X-Foo", header_value);
         129  +
            /* HttpBindingGenerator.kt:728 */
         130  +
        }
         131  +
        /* HttpBindingGenerator.kt:615 */
         132  +
    }
         133  +
    /* HttpBindingGenerator.kt:578 */
         134  +
    Ok(builder)
         135  +
    /* HttpBindingGenerator.kt:565 */
         136  +
}

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

@@ -0,1 +0,32 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_blob_payload(
           4  +
    body: &[u8],
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<::aws_smithy_types::Blob>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
          10  +
    (!body.is_empty())
          11  +
        .then(|| {
          12  +
            /* HttpBindingGenerator.kt:372 */
          13  +
            Ok(::aws_smithy_types::Blob::new(body))
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
          16  +
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
          18  +
}
          19  +
          20  +
/* HttpBindingGenerator.kt:159 */
          21  +
pub(crate) fn de_foo_header(
          22  +
    header_map: &::aws_smithy_runtime_api::http::Headers,
          23  +
) -> ::std::result::Result<
          24  +
    ::std::option::Option<::std::string::String>,
          25  +
    ::aws_smithy_legacy_http::header::ParseError,
          26  +
> {
          27  +
    /* HttpBindingGenerator.kt:166 */
          28  +
    let headers = header_map.get_all("X-Foo");
          29  +
    /* HttpBindingGenerator.kt:398 */
          30  +
    ::aws_smithy_legacy_http::header::one_or_none(headers)
          31  +
    /* HttpBindingGenerator.kt:159 */
          32  +
}

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

@@ -0,1 +0,22 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_blob_http_payload(
           4  +
    payload: ::std::option::Option<::aws_smithy_types::Blob>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:330 */
          12  +
                Vec::new(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:375 */
          19  +
        payload.into_inner(), /* HttpBoundProtocolPayloadGenerator.kt:343 */
          20  +
    )
          21  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          22  +
}

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

@@ -0,1 +0,93 @@
           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_http_payload_with_structure_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpPayloadWithStructureInput,
           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::http_payload_with_structure_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  +
            let bytes = ::hyper::body::to_bytes(body).await?;
          32  +
            if !bytes.is_empty() {
          33  +
                ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          34  +
                    &headers,
          35  +
                    Some("application/json"),
          36  +
                )?;
          37  +
            }
          38  +
            crate::protocol_serde::shape_http_payload_with_structure_input::de_nested_payload(
          39  +
                &bytes,
          40  +
            )?
          41  +
        } {
          42  +
            input = input.set_nested(Some(value))
          43  +
        }
          44  +
        /* ServerHttpBoundProtocolGenerator.kt:896 */
          45  +
        input.build()
          46  +
        /* ServerHttpBoundProtocolGenerator.kt:424 */
          47  +
    })
          48  +
    /* ServerHttpBoundProtocolGenerator.kt:408 */
          49  +
}
          50  +
          51  +
/* RustType.kt:534 */
          52  +
#[allow(clippy::unnecessary_wraps)]
          53  +
/* ServerHttpBoundProtocolGenerator.kt:445 */
          54  +
pub fn ser_http_payload_with_structure_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::HttpPayloadWithStructureOutput,
          56  +
) -> std::result::Result<
          57  +
    ::aws_smithy_legacy_http_server::response::Response,
          58  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          59  +
> {
          60  +
    /* ServerHttpBoundProtocolGenerator.kt:457 */
          61  +
    Ok({
          62  +
        /* RustType.kt:534 */
          63  +
        #[allow(unused_mut)]
          64  +
        /* ServerHttpBoundProtocolGenerator.kt:547 */
          65  +
        let mut builder = ::http::Response::builder();
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          67  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          68  +
            builder,
          69  +
            ::http::header::CONTENT_TYPE,
          70  +
            "application/json",
          71  +
        );
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          73  +
        let http_status: u16 = 200;
          74  +
        builder = builder.status(http_status);
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          76  +
        let payload =
          77  +
            /* HttpBoundProtocolPayloadGenerator.kt:348 */crate::protocol_serde::shape_http_payload_with_structure_output::ser_nested_http_payload(& output.nested)?
          78  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          79  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          80  +
        let content_length = payload.len();
          81  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          82  +
            builder,
          83  +
            ::http::header::CONTENT_LENGTH,
          84  +
            content_length,
          85  +
        );
          86  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          87  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          88  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          89  +
        builder.body(body)?
          90  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          91  +
    })
          92  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          93  +
}

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

@@ -0,1 +0,18 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBindingGenerator.kt:254 */
           3  +
pub(crate) fn de_nested_payload(
           4  +
    body: &[u8],
           5  +
) -> std::result::Result<
           6  +
    ::std::option::Option<crate::model::NestedPayload>,
           7  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           8  +
> {
           9  +
    /* HttpBindingGenerator.kt:342 */
          10  +
    (!body.is_empty())
          11  +
        .then(|| {
          12  +
            /* ServerHttpBoundProtocolGenerator.kt:914 */
          13  +
            crate::protocol_serde::shape_nested_payload::de_nested_payload_payload(body)
          14  +
            /* HttpBindingGenerator.kt:342 */
          15  +
        })
          16  +
        .transpose()
          17  +
    /* HttpBindingGenerator.kt:254 */
          18  +
}

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

@@ -0,1 +0,44 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* HttpBoundProtocolPayloadGenerator.kt:309 */
           3  +
pub fn ser_nested_http_payload(
           4  +
    payload: &::std::option::Option<crate::model::NestedPayload>,
           5  +
) -> ::std::result::Result<::std::vec::Vec<u8>, ::aws_smithy_types::error::operation::BuildError> {
           6  +
    /* HttpBoundProtocolPayloadGenerator.kt:318 */
           7  +
    let payload = match payload.as_ref() {
           8  +
        Some(t) => t,
           9  +
        None => {
          10  +
            return Ok(
          11  +
                /* HttpBoundProtocolPayloadGenerator.kt:336 */
          12  +
                crate::protocol_serde::rest_json_unset_struct_payload(), /* HttpBoundProtocolPayloadGenerator.kt:318 */
          13  +
            )
          14  +
        }
          15  +
    };
          16  +
    /* HttpBoundProtocolPayloadGenerator.kt:343 */
          17  +
    Ok(
          18  +
        /* HttpBoundProtocolPayloadGenerator.kt:384 */
          19  +
        crate::protocol_serde::shape_http_payload_with_structure_output::ser_nested_payload(
          20  +
            payload,
          21  +
        )?, /* HttpBoundProtocolPayloadGenerator.kt:343 */
          22  +
    )
          23  +
    /* HttpBoundProtocolPayloadGenerator.kt:309 */
          24  +
}
          25  +
          26  +
/* JsonSerializerGenerator.kt:240 */
          27  +
pub fn ser_nested_payload(
          28  +
    input: &crate::model::NestedPayload,
          29  +
) -> std::result::Result<
          30  +
    ::std::vec::Vec<u8>,
          31  +
    ::aws_smithy_types::error::operation::SerializationError,
          32  +
> {
          33  +
    /* JsonSerializerGenerator.kt:245 */
          34  +
    let mut out = String::new();
          35  +
    /* JsonSerializerGenerator.kt:246 */
          36  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
          37  +
    /* JsonSerializerGenerator.kt:375 */
          38  +
    crate::protocol_serde::shape_nested_payload::ser_nested_payload(&mut object, input)?;
          39  +
    /* JsonSerializerGenerator.kt:252 */
          40  +
    object.finish();
          41  +
    /* JsonSerializerGenerator.kt:253 */
          42  +
    Ok(out.into_bytes())
          43  +
    /* JsonSerializerGenerator.kt:240 */
          44  +
}