Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,97 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:358 */
           3  +
pub fn ser_farewell(
           4  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           5  +
    input: &crate::model::Farewell,
           6  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           7  +
    /* SerializerUtil.kt:46 */
           8  +
    {
           9  +
        /* JsonSerializerGenerator.kt:423 */
          10  +
        object.key("phrase").string(input.phrase.as_str());
          11  +
        /* SerializerUtil.kt:46 */
          12  +
    }
          13  +
    /* JsonSerializerGenerator.kt:372 */
          14  +
    Ok(())
          15  +
    /* JsonSerializerGenerator.kt:358 */
          16  +
}
          17  +
          18  +
/* JsonParserGenerator.kt:516 */
          19  +
pub(crate) fn de_farewell<'a, I>(
          20  +
    tokens: &mut ::std::iter::Peekable<I>,
          21  +
) -> ::std::result::Result<
          22  +
    Option<crate::model::Farewell>,
          23  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          24  +
>
          25  +
where
          26  +
    I: Iterator<
          27  +
        Item = Result<
          28  +
            ::aws_smithy_json::deserialize::Token<'a>,
          29  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          30  +
        >,
          31  +
    >,
          32  +
{
          33  +
    /* JsonParserGenerator.kt:712 */
          34  +
    match tokens.next().transpose()? {
          35  +
        /* JsonParserGenerator.kt:713 */
          36  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          37  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          38  +
            /* RustType.kt:534 */
          39  +
            #[allow(unused_mut)]
          40  +
            /* JsonParserGenerator.kt:526 */
          41  +
            let mut builder = crate::model::farewell::Builder::default();
          42  +
            /* JsonParserGenerator.kt:684 */
          43  +
            loop {
          44  +
                /* JsonParserGenerator.kt:685 */
          45  +
                match tokens.next().transpose()? {
          46  +
                    /* JsonParserGenerator.kt:686 */
          47  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          48  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          49  +
                        /* JsonParserGenerator.kt:260 */
          50  +
                        match key.to_unescaped()?.as_ref() {
          51  +
                            /* JsonParserGenerator.kt:262 */
          52  +
                            "phrase" => {
          53  +
                                /* JsonParserGenerator.kt:276 */
          54  +
                                if let Some(v) =
          55  +
                                /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          56  +
                                    /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          57  +
                                        /* JsonParserGenerator.kt:348 */u.into_owned()
          58  +
                                    /* JsonParserGenerator.kt:339 */)
          59  +
                                /* JsonParserGenerator.kt:354 */).transpose()?
          60  +
                                /* JsonParserGenerator.kt:278 */{
          61  +
                                                                            builder = builder.set_phrase(v);
          62  +
                                                                        }
          63  +
                                /* JsonParserGenerator.kt:262 */
          64  +
                            }
          65  +
                            /* JsonParserGenerator.kt:290 */
          66  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
          67  +
                        }
          68  +
                        /* JsonParserGenerator.kt:686 */
          69  +
                    }
          70  +
                    /* JsonParserGenerator.kt:695 */
          71  +
                    other => {
          72  +
                        return Err(
          73  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          74  +
                                format!("expected object key or end object, found: {other:?}"),
          75  +
                            ),
          76  +
                        )
          77  +
                    } /* JsonParserGenerator.kt:685 */
          78  +
                }
          79  +
                /* JsonParserGenerator.kt:684 */
          80  +
            }
          81  +
            /* JsonParserGenerator.kt:540 */
          82  +
            Ok(Some(builder.build()))
          83  +
            /* JsonParserGenerator.kt:713 */
          84  +
        }
          85  +
        /* JsonParserGenerator.kt:722 */
          86  +
        _ => {
          87  +
            /* JsonParserGenerator.kt:723 */
          88  +
            Err(
          89  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          90  +
                    "expected start object or null",
          91  +
                ),
          92  +
            )
          93  +
            /* JsonParserGenerator.kt:722 */
          94  +
        } /* JsonParserGenerator.kt:712 */
          95  +
    }
          96  +
    /* JsonParserGenerator.kt:516 */
          97  +
}

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

@@ -0,1 +0,80 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_foo_enum_list<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained>,
           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:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
          46  +
                        if let Some(value) = value {
          47  +
                            items.push(value);
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
          51  +
                            return Err(
          52  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                    "dense list cannot contain null values",
          54  +
                                ),
          55  +
                            );
          56  +
                        }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
          59  +
                }
          60  +
                /* JsonParserGenerator.kt:408 */
          61  +
            }
          62  +
            /* JsonParserGenerator.kt:444 */
          63  +
            Ok(Some(
          64  +
                crate::unconstrained::foo_enum_list_unconstrained::FooEnumListUnconstrained(items),
          65  +
            ))
          66  +
            /* JsonParserGenerator.kt:713 */
          67  +
        }
          68  +
        /* JsonParserGenerator.kt:722 */
          69  +
        _ => {
          70  +
            /* JsonParserGenerator.kt:723 */
          71  +
            Err(
          72  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                    "expected start array or null",
          74  +
                ),
          75  +
            )
          76  +
            /* JsonParserGenerator.kt:722 */
          77  +
        } /* JsonParserGenerator.kt:712 */
          78  +
    }
          79  +
    /* JsonParserGenerator.kt:398 */
          80  +
}

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

@@ -0,1 +0,89 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:460 */
           3  +
pub(crate) fn de_foo_enum_map<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::unconstrained::foo_enum_map_unconstrained::FooEnumMapUnconstrained>,
           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::StartObject { .. }) => {
          22  +
            /* JsonParserGenerator.kt:469 */
          23  +
            let mut map = ::std::collections::HashMap::new();
          24  +
            /* JsonParserGenerator.kt:684 */
          25  +
            loop {
          26  +
                /* JsonParserGenerator.kt:685 */
          27  +
                match tokens.next().transpose()? {
          28  +
                    /* JsonParserGenerator.kt:686 */
          29  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          30  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          31  +
                        /* JsonParserGenerator.kt:471 */
          32  +
                        let key =
          33  +
                            /* JsonParserGenerator.kt:339 */key.to_unescaped().map(|u|
          34  +
                                /* JsonParserGenerator.kt:348 */u.into_owned()
          35  +
                            /* JsonParserGenerator.kt:339 */)
          36  +
                        /* JsonParserGenerator.kt:471 */?;
          37  +
                        /* JsonParserGenerator.kt:474 */
          38  +
                        let value =
          39  +
                            /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:474 */;
          45  +
                        /* JsonParserGenerator.kt:481 */
          46  +
                        match value {
          47  +
                            Some(value) => {
          48  +
                                map.insert(key, value);
          49  +
                            }
          50  +
                            None => {
          51  +
                                return Err(
          52  +
                                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                        "dense map cannot contain null values",
          54  +
                                    ),
          55  +
                                )
          56  +
                            }
          57  +
                        }
          58  +
                        /* JsonParserGenerator.kt:686 */
          59  +
                    }
          60  +
                    /* JsonParserGenerator.kt:695 */
          61  +
                    other => {
          62  +
                        return Err(
          63  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          64  +
                                format!("expected object key or end object, found: {other:?}"),
          65  +
                            ),
          66  +
                        )
          67  +
                    } /* JsonParserGenerator.kt:685 */
          68  +
                }
          69  +
                /* JsonParserGenerator.kt:684 */
          70  +
            }
          71  +
            /* JsonParserGenerator.kt:502 */
          72  +
            Ok(Some(
          73  +
                crate::unconstrained::foo_enum_map_unconstrained::FooEnumMapUnconstrained(map),
          74  +
            ))
          75  +
            /* JsonParserGenerator.kt:713 */
          76  +
        }
          77  +
        /* JsonParserGenerator.kt:722 */
          78  +
        _ => {
          79  +
            /* JsonParserGenerator.kt:723 */
          80  +
            Err(
          81  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          82  +
                    "expected start object or null",
          83  +
                ),
          84  +
            )
          85  +
            /* JsonParserGenerator.kt:722 */
          86  +
        } /* JsonParserGenerator.kt:712 */
          87  +
    }
          88  +
    /* JsonParserGenerator.kt:460 */
          89  +
}

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

@@ -0,1 +0,80 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:398 */
           3  +
pub(crate) fn de_foo_enum_set<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained>,
           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:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
          42  +
                                /* JsonParserGenerator.kt:339 */)
          43  +
                            /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                        /* JsonParserGenerator.kt:419 */;
          45  +
                        /* JsonParserGenerator.kt:422 */
          46  +
                        if let Some(value) = value {
          47  +
                            items.push(value);
          48  +
                        }
          49  +
                        /* JsonParserGenerator.kt:430 */
          50  +
                        else {
          51  +
                            return Err(
          52  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          53  +
                                    "dense list cannot contain null values",
          54  +
                                ),
          55  +
                            );
          56  +
                        }
          57  +
                        /* JsonParserGenerator.kt:413 */
          58  +
                    } /* JsonParserGenerator.kt:409 */
          59  +
                }
          60  +
                /* JsonParserGenerator.kt:408 */
          61  +
            }
          62  +
            /* JsonParserGenerator.kt:444 */
          63  +
            Ok(Some(
          64  +
                crate::unconstrained::foo_enum_set_unconstrained::FooEnumSetUnconstrained(items),
          65  +
            ))
          66  +
            /* JsonParserGenerator.kt:713 */
          67  +
        }
          68  +
        /* JsonParserGenerator.kt:722 */
          69  +
        _ => {
          70  +
            /* JsonParserGenerator.kt:723 */
          71  +
            Err(
          72  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          73  +
                    "expected start array or null",
          74  +
                ),
          75  +
            )
          76  +
            /* JsonParserGenerator.kt:722 */
          77  +
        } /* JsonParserGenerator.kt:712 */
          78  +
    }
          79  +
    /* JsonParserGenerator.kt:398 */
          80  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_foo_error.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_foo_error_error(
           4  +
    value: &crate::error::FooError,
           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_foo_error::ser_foo_error(&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_foo_error(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::error::FooError,
          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_fractional_seconds.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_fractional_seconds_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::FractionalSecondsInput,
           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::fractional_seconds_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_fractional_seconds_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::FractionalSecondsOutput,
          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_fractional_seconds_output::ser_fractional_seconds_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_fractional_seconds_output.rs

@@ -0,1 +0,36 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
           3  +
pub fn ser_fractional_seconds_output_output_output(
           4  +
    value: &crate::output::FractionalSecondsOutput,
           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_fractional_seconds_output::ser_fractional_seconds_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_fractional_seconds_output_output(
          22  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          23  +
    input: &crate::output::FractionalSecondsOutput,
          24  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* JsonSerializerGenerator.kt:382 */
          26  +
    if let Some(var_1) = &input.datetime {
          27  +
        /* JsonSerializerGenerator.kt:448 */
          28  +
        object
          29  +
            .key("datetime")
          30  +
            .date_time(var_1, ::aws_smithy_types::date_time::Format::DateTime)?;
          31  +
        /* JsonSerializerGenerator.kt:382 */
          32  +
    }
          33  +
    /* JsonSerializerGenerator.kt:372 */
          34  +
    Ok(())
          35  +
    /* JsonSerializerGenerator.kt:358 */
          36  +
}

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

@@ -0,1 +0,95 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:516 */
           3  +
pub(crate) fn de_greeting_struct<'a, I>(
           4  +
    tokens: &mut ::std::iter::Peekable<I>,
           5  +
) -> ::std::result::Result<
           6  +
    Option<crate::model::GreetingStruct>,
           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::StartObject { .. }) => {
          22  +
            /* RustType.kt:534 */
          23  +
            #[allow(unused_mut)]
          24  +
            /* JsonParserGenerator.kt:526 */
          25  +
            let mut builder = crate::model::greeting_struct::Builder::default();
          26  +
            /* JsonParserGenerator.kt:684 */
          27  +
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
          29  +
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
          31  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          32  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          33  +
                        /* JsonParserGenerator.kt:260 */
          34  +
                        match key.to_unescaped()?.as_ref() {
          35  +
                            /* JsonParserGenerator.kt:262 */
          36  +
                            "hi" => {
          37  +
                                /* JsonParserGenerator.kt:272 */
          38  +
                                builder = builder.set_hi(
          39  +
                                    /* JsonParserGenerator.kt:354 */::aws_smithy_json::deserialize::token::expect_string_or_null(tokens.next())?.map(|s|
          40  +
                                        /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
          41  +
                                            /* JsonParserGenerator.kt:348 */u.into_owned()
          42  +
                                        /* JsonParserGenerator.kt:339 */)
          43  +
                                    /* JsonParserGenerator.kt:354 */).transpose()?
          44  +
                                /* JsonParserGenerator.kt:272 */);
          45  +
                                /* JsonParserGenerator.kt:262 */
          46  +
                            }
          47  +
                            /* JsonParserGenerator.kt:290 */
          48  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
          49  +
                        }
          50  +
                        /* JsonParserGenerator.kt:686 */
          51  +
                    }
          52  +
                    /* JsonParserGenerator.kt:695 */
          53  +
                    other => {
          54  +
                        return Err(
          55  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          56  +
                                format!("expected object key or end object, found: {other:?}"),
          57  +
                            ),
          58  +
                        )
          59  +
                    } /* JsonParserGenerator.kt:685 */
          60  +
                }
          61  +
                /* JsonParserGenerator.kt:684 */
          62  +
            }
          63  +
            /* JsonParserGenerator.kt:540 */
          64  +
            Ok(Some(builder.build()))
          65  +
            /* JsonParserGenerator.kt:713 */
          66  +
        }
          67  +
        /* JsonParserGenerator.kt:722 */
          68  +
        _ => {
          69  +
            /* JsonParserGenerator.kt:723 */
          70  +
            Err(
          71  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          72  +
                    "expected start object or null",
          73  +
                ),
          74  +
            )
          75  +
            /* JsonParserGenerator.kt:722 */
          76  +
        } /* JsonParserGenerator.kt:712 */
          77  +
    }
          78  +
    /* JsonParserGenerator.kt:516 */
          79  +
}
          80  +
          81  +
/* JsonSerializerGenerator.kt:358 */
          82  +
pub fn ser_greeting_struct(
          83  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          84  +
    input: &crate::model::GreetingStruct,
          85  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          86  +
    /* JsonSerializerGenerator.kt:382 */
          87  +
    if let Some(var_1) = &input.hi {
          88  +
        /* JsonSerializerGenerator.kt:423 */
          89  +
        object.key("hi").string(var_1.as_str());
          90  +
        /* JsonSerializerGenerator.kt:382 */
          91  +
    }
          92  +
    /* JsonSerializerGenerator.kt:372 */
          93  +
    Ok(())
          94  +
    /* JsonSerializerGenerator.kt:358 */
          95  +
}

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

@@ -0,1 +0,246 @@
           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_greeting_with_errors_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::GreetingWithErrorsInput,
           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::greeting_with_errors_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_greeting_with_errors_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::GreetingWithErrorsOutput,
          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:665 */
          56  +
        builder =
          57  +
            crate::protocol_serde::shape_greeting_with_errors::ser_greeting_with_errors_headers(
          58  +
                &output, builder,
          59  +
            )?;
          60  +
        /* ServerHttpBoundProtocolGenerator.kt:633 */
          61  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          62  +
            builder,
          63  +
            ::http::header::CONTENT_TYPE,
          64  +
            "application/json",
          65  +
        );
          66  +
        /* ServerHttpBoundProtocolGenerator.kt:718 */
          67  +
        let http_status: u16 = 200;
          68  +
        builder = builder.status(http_status);
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
          70  +
        let payload =
          71  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */;
          73  +
        /* ServerHttpBoundProtocolGenerator.kt:699 */
          74  +
        let content_length = payload.len();
          75  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          76  +
            builder,
          77  +
            ::http::header::CONTENT_LENGTH,
          78  +
            content_length,
          79  +
        );
          80  +
        /* ServerHttpBoundProtocolGenerator.kt:603 */
          81  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          82  +
        /* ServerHttpBoundProtocolGenerator.kt:611 */
          83  +
        builder.body(body)?
          84  +
        /* ServerHttpBoundProtocolGenerator.kt:457 */
          85  +
    })
          86  +
    /* ServerHttpBoundProtocolGenerator.kt:445 */
          87  +
}
          88  +
          89  +
/* RustType.kt:534 */
          90  +
#[allow(clippy::unnecessary_wraps)]
          91  +
/* ServerHttpBoundProtocolGenerator.kt:471 */
          92  +
pub fn ser_greeting_with_errors_http_error(
          93  +
    error: &crate::error::GreetingWithErrorsError,
          94  +
) -> std::result::Result<
          95  +
    ::aws_smithy_legacy_http_server::response::Response,
          96  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          97  +
> {
          98  +
    /* ServerHttpBoundProtocolGenerator.kt:476 */
          99  +
    Ok({
         100  +
        /* ServerHttpBoundProtocolGenerator.kt:492 */
         101  +
        match error {
         102  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         103  +
            crate::error::GreetingWithErrorsError::InvalidGreeting(output) => {
         104  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         105  +
                let payload =
         106  +
                    crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting_error(
         107  +
                        output,
         108  +
                    )?;
         109  +
                /* RustType.kt:534 */
         110  +
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         112  +
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         114  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         115  +
                    builder,
         116  +
                    ::http::header::CONTENT_TYPE,
         117  +
                    "application/json",
         118  +
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         120  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         121  +
                    builder,
         122  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         123  +
                    "InvalidGreeting",
         124  +
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         126  +
                let content_length = payload.len();
         127  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         128  +
                    builder,
         129  +
                    ::http::header::CONTENT_LENGTH,
         130  +
                    content_length,
         131  +
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         133  +
                builder
         134  +
                    .status(400)
         135  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         137  +
            }
         138  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         139  +
            crate::error::GreetingWithErrorsError::ComplexError(output) => {
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         141  +
                let payload =
         142  +
                    crate::protocol_serde::shape_complex_error::ser_complex_error_error(output)?;
         143  +
                /* RustType.kt:534 */
         144  +
                #[allow(unused_mut)]
         145  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         146  +
                let mut builder = ::http::Response::builder();
         147  +
                /* ServerHttpBoundProtocolGenerator.kt:665 */
         148  +
                builder = crate::protocol_serde::shape_complex_error::ser_complex_error_headers(
         149  +
                    output, builder,
         150  +
                )?;
         151  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         152  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         153  +
                    builder,
         154  +
                    ::http::header::CONTENT_TYPE,
         155  +
                    "application/json",
         156  +
                );
         157  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         158  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         159  +
                    builder,
         160  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         161  +
                    "ComplexError",
         162  +
                );
         163  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         164  +
                let content_length = payload.len();
         165  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         166  +
                    builder,
         167  +
                    ::http::header::CONTENT_LENGTH,
         168  +
                    content_length,
         169  +
                );
         170  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         171  +
                builder
         172  +
                    .status(403)
         173  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         174  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         175  +
            }
         176  +
            /* ServerHttpBoundProtocolGenerator.kt:500 */
         177  +
            crate::error::GreetingWithErrorsError::FooError(output) => {
         178  +
                /* ServerHttpBoundProtocolGenerator.kt:501 */
         179  +
                let payload = crate::protocol_serde::shape_foo_error::ser_foo_error_error(output)?;
         180  +
                /* RustType.kt:534 */
         181  +
                #[allow(unused_mut)]
         182  +
                /* ServerHttpBoundProtocolGenerator.kt:511 */
         183  +
                let mut builder = ::http::Response::builder();
         184  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         185  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         186  +
                    builder,
         187  +
                    ::http::header::CONTENT_TYPE,
         188  +
                    "application/json",
         189  +
                );
         190  +
                /* ServerHttpBoundProtocolGenerator.kt:633 */
         191  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         192  +
                    builder,
         193  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
         194  +
                    "FooError",
         195  +
                );
         196  +
                /* ServerHttpBoundProtocolGenerator.kt:699 */
         197  +
                let content_length = payload.len();
         198  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
         199  +
                    builder,
         200  +
                    ::http::header::CONTENT_LENGTH,
         201  +
                    content_length,
         202  +
                );
         203  +
                /* ServerHttpBoundProtocolGenerator.kt:528 */
         204  +
                builder
         205  +
                    .status(500)
         206  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
         207  +
                /* ServerHttpBoundProtocolGenerator.kt:500 */
         208  +
            } /* ServerHttpBoundProtocolGenerator.kt:492 */
         209  +
        }
         210  +
        /* ServerHttpBoundProtocolGenerator.kt:476 */
         211  +
    })
         212  +
    /* ServerHttpBoundProtocolGenerator.kt:471 */
         213  +
}
         214  +
         215  +
/* HttpBindingGenerator.kt:565 */
         216  +
pub fn ser_greeting_with_errors_headers(
         217  +
    input: &crate::output::GreetingWithErrorsOutput,
         218  +
    mut builder: ::http::response::Builder,
         219  +
) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
         220  +
{
         221  +
    /* HttpBindingGenerator.kt:615 */
         222  +
    if let ::std::option::Option::Some(inner_1) = &input.greeting {
         223  +
        /* HttpBindingGenerator.kt:727 */
         224  +
        let formatted_2 = inner_1.as_str();
         225  +
        /* HttpBindingGenerator.kt:728 */
         226  +
        if !formatted_2.is_empty() {
         227  +
            /* HttpBindingGenerator.kt:729 */
         228  +
            let header_value = formatted_2;
         229  +
            let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
         230  +
                ::aws_smithy_types::error::operation::BuildError::invalid_field(
         231  +
                    "greeting",
         232  +
                    format!(
         233  +
                        "`{}` cannot be used as a header value: {}",
         234  +
                        &header_value, err
         235  +
                    ),
         236  +
                )
         237  +
            })?;
         238  +
            builder = builder.header("X-Greeting", header_value);
         239  +
            /* HttpBindingGenerator.kt:728 */
         240  +
        }
         241  +
        /* HttpBindingGenerator.kt:615 */
         242  +
    }
         243  +
    /* HttpBindingGenerator.kt:578 */
         244  +
    Ok(builder)
         245  +
    /* HttpBindingGenerator.kt:565 */
         246  +
}

tmp-codegen-diff/codegen-server-test/rest_json-http0x/rust-server-codegen/src/protocol_serde/shape_greeting_with_errors_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_greeting_with_errors_output_output_output(
           4  +
    value: &crate::output::GreetingWithErrorsOutput,
           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_greeting_with_errors_output::ser_greeting_with_errors_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_greeting_with_errors_output_output(
          19  +
    #[allow(unused_variables)] object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          20  +
    #[allow(unused_variables)] input: &crate::output::GreetingWithErrorsOutput,
          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_host_with_path_operation.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_host_with_path_operation_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HostWithPathOperationInput,
           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::host_with_path_operation_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_host_with_path_operation_http_response(
          44  +
    #[allow(unused_variables)] output: crate::output::HostWithPathOperationOutput,
          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_http_checksum_required.rs

@@ -0,1 +0,163 @@
           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_checksum_required_http_request<B>(
           6  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           7  +
) -> std::result::Result<
           8  +
    crate::input::HttpChecksumRequiredInput,
           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_checksum_required_input::Builder::default();
          23  +
        /* RustType.kt:534 */
          24  +
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:764 */
          26  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          27  +
            uri, headers, body, ..
          28  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:801 */
          30  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:825 */
          32  +
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:826 */
          34  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          35  +
                &headers,
          36  +
                Some("application/json"),
          37  +
            )?;
          38  +
            input = crate::protocol_serde::shape_http_checksum_required::de_http_checksum_required(
          39  +
                bytes.as_ref(),
          40  +
                input,
          41  +
            )?;
          42  +
            /* ServerHttpBoundProtocolGenerator.kt:825 */
          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_checksum_required_http_response(
          55  +
    #[allow(unused_variables)] output: crate::output::HttpChecksumRequiredOutput,
          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:235 */crate::protocol_serde::shape_http_checksum_required_output::ser_http_checksum_required_output_output_output(&output)?
          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  +
}
          94  +
          95  +
/* JsonParserGenerator.kt:148 */
          96  +
pub(crate) fn de_http_checksum_required(
          97  +
    value: &[u8],
          98  +
    mut builder: crate::input::http_checksum_required_input::Builder,
          99  +
) -> ::std::result::Result<
         100  +
    crate::input::http_checksum_required_input::Builder,
         101  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         102  +
> {
         103  +
    /* JsonParserGenerator.kt:153 */
         104  +
    let mut tokens_owned =
         105  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         106  +
            .peekable();
         107  +
    let tokens = &mut tokens_owned;
         108  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         109  +
    /* JsonParserGenerator.kt:684 */
         110  +
    loop {
         111  +
        /* JsonParserGenerator.kt:685 */
         112  +
        match tokens.next().transpose()? {
         113  +
            /* JsonParserGenerator.kt:686 */
         114  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         115  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         116  +
                /* JsonParserGenerator.kt:260 */
         117  +
                match key.to_unescaped()?.as_ref() {
         118  +
                    /* JsonParserGenerator.kt:262 */
         119  +
                    "foo" => {
         120  +
                        /* JsonParserGenerator.kt:272 */
         121  +
                        builder = builder.set_foo(
         122  +
                            /* JsonParserGenerator.kt:354 */
         123  +
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
         124  +
                                tokens.next(),
         125  +
                            )?
         126  +
                            .map(|s|
         127  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         128  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         129  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         130  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
         131  +
                        );
         132  +
                        /* JsonParserGenerator.kt:262 */
         133  +
                    }
         134  +
                    /* JsonParserGenerator.kt:290 */
         135  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
         136  +
                }
         137  +
                /* JsonParserGenerator.kt:686 */
         138  +
            }
         139  +
            /* JsonParserGenerator.kt:695 */
         140  +
            other => {
         141  +
                return Err(
         142  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         143  +
                        "expected object key or end object, found: {other:?}"
         144  +
                    )),
         145  +
                )
         146  +
            } /* JsonParserGenerator.kt:685 */
         147  +
        }
         148  +
        /* JsonParserGenerator.kt:684 */
         149  +
    }
         150  +
    /* JsonParserGenerator.kt:250 */
         151  +
    if tokens.next().is_some() {
         152  +
        /* JsonParserGenerator.kt:251 */
         153  +
        return Err(
         154  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         155  +
                "found more JSON tokens after completing parsing",
         156  +
            ),
         157  +
        );
         158  +
        /* JsonParserGenerator.kt:250 */
         159  +
    }
         160  +
    /* JsonParserGenerator.kt:163 */
         161  +
    Ok(builder)
         162  +
    /* JsonParserGenerator.kt:148 */
         163  +
}