Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_result.rs

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

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_result_output.rs

@@ -1,1 +20,31 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_result_output_output_output(
    3      4   
    value: &crate::output::ResultOutput,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_result_output::ser_result_output_output(&mut object, value)?;
          11  +
    /* JsonSerializerGenerator.kt:227 */
    8     12   
    object.finish();
    9     13   
    Ok(out)
          14  +
    /* JsonSerializerGenerator.kt:213 */
   10     15   
}
   11     16   
          17  +
/* JsonSerializerGenerator.kt:358 */
   12     18   
pub fn ser_result_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::ResultOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.pv_member {
          24  +
        /* JsonSerializerGenerator.kt:424 */
   17     25   
        object.key("pv_member").boolean(*var_1);
          26  +
        /* JsonSerializerGenerator.kt:382 */
   18     27   
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
   19     29   
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
   20     31   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_rpc_echo.rs

@@ -1,1 +225,339 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[allow(clippy::unnecessary_wraps)]
           4  +
/* ServerHttpBoundProtocolGenerator.kt:383 */
    3      5   
pub async fn de_rpc_echo_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::RpcEchoInput,
    7      9   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
    8     10   
>
    9     11   
where
   10     12   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     13   
    B::Data: Send,
   12     14   
    ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
   13     15   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     16   
{
          17  +
    /* ServerHttpBoundProtocolGenerator.kt:399 */
   15     18   
    Ok({
          19  +
        /* RustType.kt:516 */
   16     20   
        #[allow(unused_mut)]
          21  +
        /* ServerHttpBoundProtocolGenerator.kt:723 */
   17     22   
        let mut input = crate::input::rpc_echo_input_internal::Builder::default();
          23  +
        /* RustType.kt:516 */
   18     24   
        #[allow(unused_variables)]
          25  +
        /* ServerHttpBoundProtocolGenerator.kt:728 */
   19     26   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     27   
            uri, headers, body, ..
   21     28   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          29  +
        /* ServerHttpBoundProtocolGenerator.kt:745 */
   22     30   
        let bytes = ::hyper::body::to_bytes(body).await?;
          31  +
        /* ServerHttpBoundProtocolGenerator.kt:768 */
   23     32   
        if !bytes.is_empty() {
          33  +
            /* ServerHttpBoundProtocolGenerator.kt:769 */
   24     34   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     35   
                &headers,
   26     36   
                Some("application/x-amz-json-1.1"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_rpc_echo::de_rpc_echo(bytes.as_ref(), input)?;
          39  +
            /* ServerHttpBoundProtocolGenerator.kt:768 */
   29     40   
        }
          41  +
        /* ServerHttpBoundProtocolGenerator.kt:834 */
   30     42   
        input.build()?
          43  +
        /* ServerHttpBoundProtocolGenerator.kt:399 */
   31     44   
    })
          45  +
    /* ServerHttpBoundProtocolGenerator.kt:383 */
   32     46   
}
   33     47   
          48  +
/* RustType.kt:516 */
   34     49   
#[allow(clippy::unnecessary_wraps)]
          50  +
/* ServerHttpBoundProtocolGenerator.kt:421 */
   35     51   
pub fn ser_rpc_echo_http_response(
   36     52   
    #[allow(unused_variables)] output: crate::output::RpcEchoOutput,
   37     53   
) -> std::result::Result<
   38     54   
    ::aws_smithy_http_server::response::Response,
   39     55   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   40     56   
> {
          57  +
    /* ServerHttpBoundProtocolGenerator.kt:433 */
   41     58   
    Ok({
          59  +
        /* RustType.kt:516 */
   42     60   
        #[allow(unused_mut)]
          61  +
        /* ServerHttpBoundProtocolGenerator.kt:523 */
   43     62   
        let mut builder = ::http::Response::builder();
          63  +
        /* ServerHttpBoundProtocolGenerator.kt:597 */
   44     64   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     65   
            builder,
   46     66   
            ::http::header::CONTENT_TYPE,
   47     67   
            "application/x-amz-json-1.1",
   48     68   
        );
          69  +
        /* ServerHttpBoundProtocolGenerator.kt:682 */
   49     70   
        let http_status: u16 = 200;
   50     71   
        builder = builder.status(http_status);
   51         -
        let payload = "";
          72  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */
          73  +
        let payload =
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:235 */""
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   52     77   
        let content_length = payload.len();
   53     78   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   54     79   
            builder,
   55     80   
            ::http::header::CONTENT_LENGTH,
   56     81   
            content_length,
   57     82   
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   58     84   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   59     86   
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   60     88   
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   61     90   
}
   62     91   
          92  +
/* RustType.kt:516 */
   63     93   
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   64     95   
pub fn ser_rpc_echo_http_error(
   65     96   
    error: &crate::error::RPCEchoError,
   66     97   
) -> std::result::Result<
   67     98   
    ::aws_smithy_http_server::response::Response,
   68     99   
    ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
   69    100   
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   70    102   
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   71    104   
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   72    106   
            crate::error::RPCEchoError::ValidationException(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   73    108   
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
         109  +
                /* RustType.kt:516 */
   74    110   
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   75    112   
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   76    114   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   77    115   
                    builder,
   78    116   
                    ::http::header::CONTENT_TYPE,
   79    117   
                    "application/x-amz-json-1.1",
   80    118   
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   81    120   
                let content_length = payload.len();
   82    121   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   83    122   
                    builder,
   84    123   
                    ::http::header::CONTENT_LENGTH,
   85    124   
                    content_length,
   86    125   
                );
         126  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   87    127   
                builder
   88    128   
                    .status(400)
   89    129   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         130  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
   90    131   
            }
         132  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   91    133   
            crate::error::RPCEchoError::InternalServerError(output) => {
         134  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   92    135   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         136  +
                /* RustType.kt:516 */
   93    137   
                #[allow(unused_mut)]
         138  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   94    139   
                let mut builder = ::http::Response::builder();
         140  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   95    141   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   96    142   
                    builder,
   97    143   
                    ::http::header::CONTENT_TYPE,
   98    144   
                    "application/x-amz-json-1.1",
   99    145   
                );
         146  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
  100    147   
                let content_length = payload.len();
  101    148   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
  102    149   
                    builder,
  103    150   
                    ::http::header::CONTENT_LENGTH,
  104    151   
                    content_length,
  105    152   
                );
         153  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
  106    154   
                builder
  107    155   
                    .status(500)
  108    156   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
         157  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         158  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
  109    159   
        }
  110         -
        }
         160  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  111    161   
    })
         162  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  112    163   
}
  113    164   
         165  +
/* JsonParserGenerator.kt:148 */
  114    166   
pub(crate) fn de_rpc_echo(
  115    167   
    value: &[u8],
  116    168   
    mut builder: crate::input::rpc_echo_input_internal::Builder,
  117    169   
) -> ::std::result::Result<
  118    170   
    crate::input::rpc_echo_input_internal::Builder,
  119    171   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  120    172   
> {
         173  +
    /* JsonParserGenerator.kt:153 */
  121    174   
    let mut tokens_owned =
  122    175   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  123    176   
            .peekable();
  124    177   
    let tokens = &mut tokens_owned;
  125    178   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         179  +
    /* JsonParserGenerator.kt:684 */
  126    180   
    loop {
         181  +
        /* JsonParserGenerator.kt:685 */
  127    182   
        match tokens.next().transpose()? {
         183  +
            /* JsonParserGenerator.kt:686 */
  128    184   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  129    185   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         186  +
                /* JsonParserGenerator.kt:260 */
  130    187   
                match key.to_unescaped()?.as_ref() {
         188  +
                    /* JsonParserGenerator.kt:262 */
  131    189   
                    "as" => {
         190  +
                        /* JsonParserGenerator.kt:272 */
  132    191   
                        builder = builder.set_as(
         192  +
                            /* JsonParserGenerator.kt:365 */
  133    193   
                            ::aws_smithy_json::deserialize::token::expect_number_or_null(
  134    194   
                                tokens.next(),
  135    195   
                            )?
  136    196   
                            .map(i32::try_from)
  137         -
                            .transpose()?,
         197  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  138    198   
                        );
         199  +
                        /* JsonParserGenerator.kt:262 */
  139    200   
                    }
         201  +
                    /* JsonParserGenerator.kt:262 */
  140    202   
                    "async" => {
         203  +
                        /* JsonParserGenerator.kt:272 */
  141    204   
                        builder = builder.set_async(
         205  +
                            /* JsonParserGenerator.kt:298 */
  142    206   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  143    207   
                                tokens.next(),
  144         -
                            )?,
         208  +
                            )?, /* JsonParserGenerator.kt:272 */
  145    209   
                        );
         210  +
                        /* JsonParserGenerator.kt:262 */
  146    211   
                    }
         212  +
                    /* JsonParserGenerator.kt:262 */
  147    213   
                    "enum" => {
         214  +
                        /* JsonParserGenerator.kt:272 */
  148    215   
                        builder = builder.set_enum(
         216  +
                            /* JsonParserGenerator.kt:354 */
  149    217   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  150    218   
                                tokens.next(),
  151    219   
                            )?
  152         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  153         -
                            .transpose()?,
         220  +
                            .map(|s|
         221  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         222  +
                                    /* JsonParserGenerator.kt:343 */u.into_owned()
         223  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         224  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  154    225   
                        );
         226  +
                        /* JsonParserGenerator.kt:262 */
  155    227   
                    }
         228  +
                    /* JsonParserGenerator.kt:262 */
  156    229   
                    "self" => {
         230  +
                        /* JsonParserGenerator.kt:272 */
  157    231   
                        builder = builder.set_self(
         232  +
                            /* JsonParserGenerator.kt:298 */
  158    233   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  159    234   
                                tokens.next(),
  160         -
                            )?,
         235  +
                            )?, /* JsonParserGenerator.kt:272 */
  161    236   
                        );
         237  +
                        /* JsonParserGenerator.kt:262 */
  162    238   
                    }
         239  +
                    /* JsonParserGenerator.kt:262 */
  163    240   
                    "crate" => {
         241  +
                        /* JsonParserGenerator.kt:272 */
  164    242   
                        builder = builder.set_crate(
         243  +
                            /* JsonParserGenerator.kt:298 */
  165    244   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  166    245   
                                tokens.next(),
  167         -
                            )?,
         246  +
                            )?, /* JsonParserGenerator.kt:272 */
  168    247   
                        );
         248  +
                        /* JsonParserGenerator.kt:262 */
  169    249   
                    }
         250  +
                    /* JsonParserGenerator.kt:262 */
  170    251   
                    "super" => {
         252  +
                        /* JsonParserGenerator.kt:272 */
  171    253   
                        builder = builder.set_super(
         254  +
                            /* JsonParserGenerator.kt:298 */
  172    255   
                            ::aws_smithy_json::deserialize::token::expect_bool_or_null(
  173    256   
                                tokens.next(),
  174         -
                            )?,
         257  +
                            )?, /* JsonParserGenerator.kt:272 */
  175    258   
                        );
         259  +
                        /* JsonParserGenerator.kt:262 */
  176    260   
                    }
         261  +
                    /* JsonParserGenerator.kt:262 */
  177    262   
                    "build" => {
         263  +
                        /* JsonParserGenerator.kt:272 */
  178    264   
                        builder = builder.set_build(
         265  +
                            /* JsonParserGenerator.kt:354 */
  179    266   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  180    267   
                                tokens.next(),
  181    268   
                            )?
  182         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  183         -
                            .transpose()?,
         269  +
                            .map(|s|
         270  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         271  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         272  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         273  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  184    274   
                        );
         275  +
                        /* JsonParserGenerator.kt:262 */
  185    276   
                    }
         277  +
                    /* JsonParserGenerator.kt:262 */
  186    278   
                    "default" => {
         279  +
                        /* JsonParserGenerator.kt:272 */
  187    280   
                        builder = builder.set_default(
         281  +
                            /* JsonParserGenerator.kt:354 */
  188    282   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  189    283   
                                tokens.next(),
  190    284   
                            )?
  191         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  192         -
                            .transpose()?,
         285  +
                            .map(|s|
         286  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         287  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         288  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         289  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  193    290   
                        );
         291  +
                        /* JsonParserGenerator.kt:262 */
  194    292   
                    }
         293  +
                    /* JsonParserGenerator.kt:262 */
  195    294   
                    "send" => {
         295  +
                        /* JsonParserGenerator.kt:272 */
  196    296   
                        builder = builder.set_send(
         297  +
                            /* JsonParserGenerator.kt:354 */
  197    298   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  198    299   
                                tokens.next(),
  199    300   
                            )?
  200         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  201         -
                            .transpose()?,
         301  +
                            .map(|s|
         302  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         303  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         304  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         305  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  202    306   
                        );
         307  +
                        /* JsonParserGenerator.kt:262 */
  203    308   
                    }
  204         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         309  +
                    /* JsonParserGenerator.kt:290 */
         310  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  205    311   
                }
         312  +
                /* JsonParserGenerator.kt:686 */
  206    313   
            }
         314  +
            /* JsonParserGenerator.kt:695 */
  207    315   
            other => {
  208    316   
                return Err(
  209    317   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  210    318   
                        "expected object key or end object, found: {:?}",
  211    319   
                        other
  212    320   
                    )),
  213    321   
                )
         322  +
            } /* JsonParserGenerator.kt:685 */
  214    323   
        }
         324  +
        /* JsonParserGenerator.kt:684 */
  215    325   
    }
  216         -
    }
         326  +
    /* JsonParserGenerator.kt:250 */
  217    327   
    if tokens.next().is_some() {
         328  +
        /* JsonParserGenerator.kt:251 */
  218    329   
        return Err(
  219    330   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  220    331   
                "found more JSON tokens after completing parsing",
  221    332   
            ),
  222    333   
        );
         334  +
        /* JsonParserGenerator.kt:250 */
  223    335   
    }
         336  +
    /* JsonParserGenerator.kt:163 */
  224    337   
    Ok(builder)
         338  +
    /* JsonParserGenerator.kt:148 */
  225    339   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_structure_name_punning.rs

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

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_validation_exception.rs

@@ -1,1 +36,60 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_validation_exception_error(
    3      4   
    value: &crate::error::ValidationException,
    4      5   
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    /* JsonSerializerGenerator.kt:218 */
    5      7   
    let mut out = ::std::string::String::new();
    6      8   
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           9  +
    /* JsonSerializerGenerator.kt:375 */
    7     10   
    crate::protocol_serde::shape_validation_exception::ser_validation_exception(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* ServerAwsJson.kt:95 */
   11     15   
    object.key("__type").string("ValidationException");
          16  +
    /* JsonSerializerGenerator.kt:227 */
   12     17   
    object.finish();
   13     18   
    Ok(out)
          19  +
    /* JsonSerializerGenerator.kt:213 */
   14     20   
}
   15     21   
          22  +
/* JsonSerializerGenerator.kt:358 */
   16     23   
pub fn ser_validation_exception(
   17     24   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   18     25   
    input: &crate::error::ValidationException,
   19     26   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          27  +
    /* SerializerUtil.kt:42 */
   20     28   
    {
          29  +
        /* JsonSerializerGenerator.kt:423 */
   21     30   
        object.key("message").string(input.message.as_str());
          31  +
        /* SerializerUtil.kt:42 */
   22     32   
    }
          33  +
    /* JsonSerializerGenerator.kt:382 */
   23     34   
    if let Some(var_1) = &input.field_list {
          35  +
        /* JsonSerializerGenerator.kt:484 */
   24     36   
        let mut array_2 = object.key("fieldList").start_array();
          37  +
        /* JsonSerializerGenerator.kt:524 */
   25     38   
        for item_3 in var_1 {
          39  +
            /* SerializerUtil.kt:42 */
   26     40   
            {
          41  +
                /* JsonSerializerGenerator.kt:495 */
   27     42   
                #[allow(unused_mut)]
          43  +
                /* JsonSerializerGenerator.kt:496 */
   28     44   
                let mut object_4 = array_2.value().start_object();
          45  +
                /* JsonSerializerGenerator.kt:375 */
   29     46   
                crate::protocol_serde::shape_validation_exception_field::ser_validation_exception_field(&mut object_4, item_3)?;
          47  +
                /* JsonSerializerGenerator.kt:515 */
   30     48   
                object_4.finish();
          49  +
                /* SerializerUtil.kt:42 */
   31     50   
            }
          51  +
            /* JsonSerializerGenerator.kt:524 */
   32     52   
        }
          53  +
        /* JsonSerializerGenerator.kt:486 */
   33     54   
        array_2.finish();
          55  +
        /* JsonSerializerGenerator.kt:382 */
   34     56   
    }
          57  +
    /* JsonSerializerGenerator.kt:372 */
   35     58   
    Ok(())
          59  +
    /* JsonSerializerGenerator.kt:358 */
   36     60   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_validation_exception_field.rs

@@ -1,1 +13,22 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:358 */
    2      3   
pub fn ser_validation_exception_field(
    3      4   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
    4      5   
    input: &crate::model::ValidationExceptionField,
    5      6   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           7  +
    /* SerializerUtil.kt:42 */
    6      8   
    {
           9  +
        /* JsonSerializerGenerator.kt:423 */
    7     10   
        object.key("path").string(input.path.as_str());
          11  +
        /* SerializerUtil.kt:42 */
    8     12   
    }
          13  +
    /* SerializerUtil.kt:42 */
    9     14   
    {
          15  +
        /* JsonSerializerGenerator.kt:423 */
   10     16   
        object.key("message").string(input.message.as_str());
          17  +
        /* SerializerUtil.kt:42 */
   11     18   
    }
          19  +
    /* JsonSerializerGenerator.kt:372 */
   12     20   
    Ok(())
          21  +
    /* JsonSerializerGenerator.kt:358 */
   13     22   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/protocol_serde/shape_vec.rs

@@ -1,1 +53,78 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonParserGenerator.kt:516 */
    2      3   
pub(crate) fn de_vec<'a, I>(
    3      4   
    tokens: &mut ::std::iter::Peekable<I>,
    4      5   
) -> ::std::result::Result<
    5      6   
    Option<crate::model::Vec>,
    6      7   
    ::aws_smithy_json::deserialize::error::DeserializeError,
    7      8   
>
    8      9   
where
    9     10   
    I: Iterator<
   10     11   
        Item = Result<
   11     12   
            ::aws_smithy_json::deserialize::Token<'a>,
   12     13   
            ::aws_smithy_json::deserialize::error::DeserializeError,
   13     14   
        >,
   14     15   
    >,
   15     16   
{
          17  +
    /* JsonParserGenerator.kt:712 */
   16     18   
    match tokens.next().transpose()? {
          19  +
        /* JsonParserGenerator.kt:713 */
   17     20   
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
   18     21   
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          22  +
            /* RustType.kt:516 */
   19     23   
            #[allow(unused_mut)]
          24  +
            /* JsonParserGenerator.kt:526 */
   20     25   
            let mut builder = crate::model::vec_internal::Builder::default();
          26  +
            /* JsonParserGenerator.kt:684 */
   21     27   
            loop {
          28  +
                /* JsonParserGenerator.kt:685 */
   22     29   
                match tokens.next().transpose()? {
          30  +
                    /* JsonParserGenerator.kt:686 */
   23     31   
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   24     32   
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          33  +
                        /* JsonParserGenerator.kt:260 */
   25     34   
                        match key.to_unescaped()?.as_ref() {
          35  +
                            /* JsonParserGenerator.kt:262 */
   26     36   
                            "pv_member" => {
          37  +
                                /* JsonParserGenerator.kt:272 */
   27     38   
                                builder = builder.set_pv_member(
          39  +
                                    /* JsonParserGenerator.kt:298 */
   28     40   
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(
   29     41   
                                        tokens.next(),
   30         -
                                    )?,
          42  +
                                    )?, /* JsonParserGenerator.kt:272 */
   31     43   
                                );
          44  +
                                /* JsonParserGenerator.kt:262 */
   32     45   
                            }
   33         -
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          46  +
                            /* JsonParserGenerator.kt:290 */
          47  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   34     48   
                        }
          49  +
                        /* JsonParserGenerator.kt:686 */
   35     50   
                    }
          51  +
                    /* JsonParserGenerator.kt:695 */
   36     52   
                    other => {
   37     53   
                        return Err(
   38     54   
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   39     55   
                                format!("expected object key or end object, found: {:?}", other),
   40     56   
                            ),
   41     57   
                        )
          58  +
                    } /* JsonParserGenerator.kt:685 */
   42     59   
                }
          60  +
                /* JsonParserGenerator.kt:684 */
   43     61   
            }
   44         -
            }
          62  +
            /* JsonParserGenerator.kt:540 */
   45     63   
            Ok(Some(builder.build()))
          64  +
            /* JsonParserGenerator.kt:713 */
   46     65   
        }
   47         -
        _ => Err(
          66  +
        /* JsonParserGenerator.kt:722 */
          67  +
        _ => {
          68  +
            /* JsonParserGenerator.kt:723 */
          69  +
            Err(
   48     70   
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
   49     71   
                    "expected start object or null",
   50     72   
                ),
   51         -
        ),
          73  +
            )
          74  +
            /* JsonParserGenerator.kt:722 */
          75  +
        } /* JsonParserGenerator.kt:712 */
   52     76   
    }
          77  +
    /* JsonParserGenerator.kt:516 */
   53     78   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/python_module_export.rs

@@ -1,1 +118,154 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonServerModuleGenerator.kt:41 */
    2      3   
#[::pyo3::pymodule]
    3         -
#[::pyo3(name = "naming_test_ops")]
           4  +
#[pyo3(name = "naming_test_ops")]
    4      5   
pub fn python_library(py: ::pyo3::Python<'_>, m: &::pyo3::types::PyModule) -> ::pyo3::PyResult<()> {
           6  +
    /* PythonServerModuleGenerator.kt:65 */
    5      7   
    let input = ::pyo3::types::PyModule::new(py, "input")?;
    6      8   
    let output = ::pyo3::types::PyModule::new(py, "output")?;
    7      9   
    let error = ::pyo3::types::PyModule::new(py, "error")?;
          10  +
    /* PythonServerModuleGenerator.kt:96 */
    8     11   
    error.add_class::<crate::error::InternalServerError>()?;
          12  +
    /* PythonServerModuleGenerator.kt:96 */
    9     13   
    error.add_class::<crate::error::ValidationException>()?;
          14  +
    /* PythonServerModuleGenerator.kt:79 */
   10     15   
    let model = ::pyo3::types::PyModule::new(py, "model")?;
          16  +
    /* PythonServerModuleGenerator.kt:96 */
   11     17   
    model.add_class::<crate::model::ValidationExceptionField>()?;
          18  +
    /* PythonServerModuleGenerator.kt:96 */
   12     19   
    output.add_class::<crate::output::RpcEchoOutput>()?;
          20  +
    /* PythonServerModuleGenerator.kt:96 */
   13     21   
    input.add_class::<crate::input::RpcEchoInput>()?;
          22  +
    /* PythonServerModuleGenerator.kt:96 */
   14     23   
    model.add_class::<crate::model::UnknownVariantCollidingEnum>()?;
          24  +
    /* PythonServerModuleGenerator.kt:96 */
   15     25   
    output.add_class::<crate::output::MatchOutput>()?;
          26  +
    /* PythonServerModuleGenerator.kt:96 */
   16     27   
    input.add_class::<crate::input::MatchInput>()?;
          28  +
    /* PythonServerModuleGenerator.kt:96 */
   17     29   
    output.add_class::<crate::output::OptionOutput>()?;
          30  +
    /* PythonServerModuleGenerator.kt:96 */
   18     31   
    input.add_class::<crate::input::OptionInput>()?;
          32  +
    /* PythonServerModuleGenerator.kt:96 */
   19     33   
    output.add_class::<crate::output::ResultOutput>()?;
          34  +
    /* PythonServerModuleGenerator.kt:96 */
   20     35   
    input.add_class::<crate::input::ResultInput>()?;
          36  +
    /* PythonServerModuleGenerator.kt:96 */
   21     37   
    error.add_class::<crate::error::CollidingException>()?;
          38  +
    /* PythonServerModuleGenerator.kt:96 */
   22     39   
    error.add_class::<crate::error::CollidingError>()?;
          40  +
    /* PythonServerModuleGenerator.kt:96 */
   23     41   
    output.add_class::<crate::output::ErrCollisionsOutput>()?;
          42  +
    /* PythonServerModuleGenerator.kt:96 */
   24     43   
    input.add_class::<crate::input::ErrCollisionsInput>()?;
          44  +
    /* PythonServerModuleGenerator.kt:96 */
   25     45   
    output.add_class::<crate::output::StructureNamePunningOutput>()?;
          46  +
    /* PythonServerModuleGenerator.kt:96 */
   26     47   
    input.add_class::<crate::input::StructureNamePunningInput>()?;
          48  +
    /* PythonServerModuleGenerator.kt:96 */
   27     49   
    model.add_class::<crate::model::Vec>()?;
          50  +
    /* PythonServerModuleGenerator.kt:96 */
   28     51   
    output.add_class::<crate::output::ReservedWordsAsMembersOutput>()?;
          52  +
    /* PythonServerModuleGenerator.kt:96 */
   29     53   
    input.add_class::<crate::input::ReservedWordsAsMembersInput>()?;
          54  +
    /* PythonServerModuleGenerator.kt:105 */
   30     55   
    ::pyo3::py_run!(
   31     56   
        py,
   32     57   
        input,
   33     58   
        "import sys; sys.modules['naming_test_ops.input'] = input"
   34     59   
    );
   35     60   
    m.add_submodule(input)?;
   36     61   
    ::pyo3::py_run!(
   37     62   
        py,
   38     63   
        output,
   39     64   
        "import sys; sys.modules['naming_test_ops.output'] = output"
   40     65   
    );
   41     66   
    m.add_submodule(output)?;
   42     67   
    ::pyo3::py_run!(
   43     68   
        py,
   44     69   
        error,
   45     70   
        "import sys; sys.modules['naming_test_ops.error'] = error"
   46     71   
    );
   47     72   
    m.add_submodule(error)?;
          73  +
    /* PythonServerModuleGenerator.kt:117 */
   48     74   
    ::pyo3::py_run!(
   49     75   
        py,
   50     76   
        model,
   51     77   
        "import sys; sys.modules['naming_test_ops.model'] = model"
   52     78   
    );
   53     79   
    m.add_submodule(model)?;
          80  +
    /* PythonServerModuleGenerator.kt:129 */
   54     81   
    let types = ::pyo3::types::PyModule::new(py, "types")?;
   55     82   
    types.add_class::<::aws_smithy_http_server_python::types::Blob>()?;
   56     83   
    types.add_class::<::aws_smithy_http_server_python::types::DateTime>()?;
   57     84   
    types.add_class::<::aws_smithy_http_server_python::types::Format>()?;
   58     85   
    types.add_class::<::aws_smithy_http_server_python::types::ByteStream>()?;
   59     86   
    ::pyo3::py_run!(
   60     87   
        py,
   61     88   
        types,
   62     89   
        "import sys; sys.modules['naming_test_ops.types'] = types"
   63     90   
    );
   64     91   
    m.add_submodule(types)?;
          92  +
    /* PythonServerModuleGenerator.kt:149 */
   65     93   
    let socket = ::pyo3::types::PyModule::new(py, "socket")?;
   66     94   
    socket.add_class::<::aws_smithy_http_server_python::PySocket>()?;
   67     95   
    ::pyo3::py_run!(
   68     96   
        py,
   69     97   
        socket,
   70     98   
        "import sys; sys.modules['naming_test_ops.socket'] = socket"
   71     99   
    );
   72    100   
    m.add_submodule(socket)?;
         101  +
    /* PythonServerModuleGenerator.kt:166 */
   73    102   
    let logging = ::pyo3::types::PyModule::new(py, "logging")?;
   74    103   
    logging.add_function(::pyo3::wrap_pyfunction!(
   75    104   
        ::aws_smithy_http_server_python::py_tracing_event,
   76    105   
        m
   77    106   
    )?)?;
   78    107   
    logging.add_class::<::aws_smithy_http_server_python::PyTracingHandler>()?;
   79    108   
    ::pyo3::py_run!(
   80    109   
        py,
   81    110   
        logging,
   82    111   
        "import sys; sys.modules['naming_test_ops.logging'] = logging"
   83    112   
    );
   84    113   
    m.add_submodule(logging)?;
         114  +
    /* PythonServerModuleGenerator.kt:183 */
   85    115   
    let middleware = ::pyo3::types::PyModule::new(py, "middleware")?;
   86    116   
    middleware.add_class::<::aws_smithy_http_server_python::PyRequest>()?;
   87    117   
    middleware.add_class::<::aws_smithy_http_server_python::PyResponse>()?;
   88    118   
    middleware.add_class::<::aws_smithy_http_server_python::PyMiddlewareException>()?;
   89    119   
    pyo3::py_run!(
   90    120   
        py,
   91    121   
        middleware,
   92    122   
        "import sys; sys.modules['naming_test_ops.middleware'] = middleware"
   93    123   
    );
   94    124   
    m.add_submodule(middleware)?;
         125  +
    /* PythonServerModuleGenerator.kt:201 */
   95    126   
    let tls = ::pyo3::types::PyModule::new(py, "tls")?;
   96    127   
    tls.add_class::<::aws_smithy_http_server_python::tls::PyTlsConfig>()?;
   97    128   
    pyo3::py_run!(
   98    129   
        py,
   99    130   
        tls,
  100    131   
        "import sys; sys.modules['naming_test_ops.tls'] = tls"
  101    132   
    );
  102    133   
    m.add_submodule(tls)?;
         134  +
    /* PythonServerModuleGenerator.kt:217 */
  103    135   
    let aws_lambda = ::pyo3::types::PyModule::new(py, "aws_lambda")?;
  104    136   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyLambdaContext>()?;
  105    137   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientApplication>()?;
  106    138   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyClientContext>()?;
  107    139   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyCognitoIdentity>()?;
  108    140   
    aws_lambda.add_class::<::aws_smithy_http_server_python::lambda::PyConfig>()?;
  109    141   
    pyo3::py_run!(
  110    142   
        py,
  111    143   
        aws_lambda,
  112    144   
        "import sys; sys.modules['naming_test_ops.aws_lambda'] = aws_lambda"
  113    145   
    );
  114    146   
    m.add_submodule(aws_lambda)?;
         147  +
    /* PythonServerModuleGenerator.kt:238 */
  115    148   
    m.add_class::<crate::python_server_application::App>()?;
         149  +
    /* PythonServerModuleGenerator.kt:243 */
  116    150   
    m.add("CODEGEN_VERSION", "ci")?;
         151  +
    /* PythonServerModuleGenerator.kt:58 */
  117    152   
    Ok(())
         153  +
    /* PythonServerModuleGenerator.kt:41 */
  118    154   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/python_operation_adaptor.rs

@@ -1,1 +309,316 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonServerOperationHandlerGenerator.kt:61 */
    2      3   
/// Python handler for operation `RPCEcho`.
    3      4   
pub(crate) async fn rpc_echo(
    4      5   
    input: crate::input::RpcEchoInput,
    5      6   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
    6      7   
    handler: ::aws_smithy_http_server_python::PyHandler,
    7      8   
) -> std::result::Result<crate::output::RpcEchoOutput, crate::error::RPCEchoError> {
    8      9   
    // Async block used to run the handler and catch any Python error.
    9     10   
    let result = if handler.is_coroutine {
   10     11   
        ::tracing::trace!(name = "rpc_echo", "executing python handler coroutine");
   11     12   
        let result = ::pyo3::Python::with_gil(|py| {
   12     13   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   13     14   
            let coroutine = if handler.args == 1 {
   14     15   
                pyhandler.call1((input,))?
   15     16   
            } else {
   16     17   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   17     18   
            };
   18     19   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   19     20   
        })?;
   20     21   
        result.await.and_then(|r| {
   21     22   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::RpcEchoOutput>(py))
   22     23   
        })
   23     24   
    } else {
   24     25   
        ::tracing::trace!(name = "rpc_echo", "executing python handler function");
   25     26   
        ::pyo3::Python::with_gil(|py| {
   26     27   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   27     28   
            let output = if handler.args == 1 {
   28     29   
                pyhandler.call1((input,))?
   29     30   
            } else {
   30     31   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   31     32   
            };
   32     33   
            output.extract::<crate::output::RpcEchoOutput>()
   33     34   
        })
   34     35   
    };
   35     36   
    // Catch and record a Python traceback.
   36     37   
    result.map_err(|e| {
   37     38   
        let rich_py_err =
   38     39   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
   39     40   
                e.clone_ref(py)
   40     41   
            }));
   41     42   
        ::tracing::error!(error = ?rich_py_err, "handler error");
   42     43   
        e.into()
   43     44   
    })
   44     45   
}
   45     46   
          47  +
/* PythonServerOperationHandlerGenerator.kt:61 */
   46     48   
/// Python handler for operation `Match`.
   47     49   
pub(crate) async fn r#match(
   48     50   
    input: crate::input::MatchInput,
   49     51   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
   50     52   
    handler: ::aws_smithy_http_server_python::PyHandler,
   51     53   
) -> std::result::Result<crate::output::MatchOutput, crate::error::MatchError> {
   52     54   
    // Async block used to run the handler and catch any Python error.
   53     55   
    let result = if handler.is_coroutine {
   54     56   
        ::tracing::trace!(name = "r#match", "executing python handler coroutine");
   55     57   
        let result = ::pyo3::Python::with_gil(|py| {
   56     58   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   57     59   
            let coroutine = if handler.args == 1 {
   58     60   
                pyhandler.call1((input,))?
   59     61   
            } else {
   60     62   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   61     63   
            };
   62     64   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   63     65   
        })?;
   64     66   
        result.await.and_then(|r| {
   65     67   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::MatchOutput>(py))
   66     68   
        })
   67     69   
    } else {
   68     70   
        ::tracing::trace!(name = "r#match", "executing python handler function");
   69     71   
        ::pyo3::Python::with_gil(|py| {
   70     72   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   71     73   
            let output = if handler.args == 1 {
   72     74   
                pyhandler.call1((input,))?
   73     75   
            } else {
   74     76   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   75     77   
            };
   76     78   
            output.extract::<crate::output::MatchOutput>()
   77     79   
        })
   78     80   
    };
   79     81   
    // Catch and record a Python traceback.
   80     82   
    result.map_err(|e| {
   81     83   
        let rich_py_err =
   82     84   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
   83     85   
                e.clone_ref(py)
   84     86   
            }));
   85     87   
        ::tracing::error!(error = ?rich_py_err, "handler error");
   86     88   
        e.into()
   87     89   
    })
   88     90   
}
   89     91   
          92  +
/* PythonServerOperationHandlerGenerator.kt:61 */
   90     93   
/// Python handler for operation `Option`.
   91     94   
pub(crate) async fn option(
   92     95   
    input: crate::input::OptionInput,
   93     96   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
   94     97   
    handler: ::aws_smithy_http_server_python::PyHandler,
   95     98   
) -> std::result::Result<crate::output::OptionOutput, crate::error::OptionError> {
   96     99   
    // Async block used to run the handler and catch any Python error.
   97    100   
    let result = if handler.is_coroutine {
   98    101   
        ::tracing::trace!(name = "option", "executing python handler coroutine");
   99    102   
        let result = ::pyo3::Python::with_gil(|py| {
  100    103   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  101    104   
            let coroutine = if handler.args == 1 {
  102    105   
                pyhandler.call1((input,))?
  103    106   
            } else {
  104    107   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  105    108   
            };
  106    109   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  107    110   
        })?;
  108    111   
        result.await.and_then(|r| {
  109    112   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::OptionOutput>(py))
  110    113   
        })
  111    114   
    } else {
  112    115   
        ::tracing::trace!(name = "option", "executing python handler function");
  113    116   
        ::pyo3::Python::with_gil(|py| {
  114    117   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  115    118   
            let output = if handler.args == 1 {
  116    119   
                pyhandler.call1((input,))?
  117    120   
            } else {
  118    121   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  119    122   
            };
  120    123   
            output.extract::<crate::output::OptionOutput>()
  121    124   
        })
  122    125   
    };
  123    126   
    // Catch and record a Python traceback.
  124    127   
    result.map_err(|e| {
  125    128   
        let rich_py_err =
  126    129   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  127    130   
                e.clone_ref(py)
  128    131   
            }));
  129    132   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  130    133   
        e.into()
  131    134   
    })
  132    135   
}
  133    136   
         137  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  134    138   
/// Python handler for operation `Result`.
  135    139   
pub(crate) async fn result(
  136    140   
    input: crate::input::ResultInput,
  137    141   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  138    142   
    handler: ::aws_smithy_http_server_python::PyHandler,
  139    143   
) -> std::result::Result<crate::output::ResultOutput, crate::error::ResultError> {
  140    144   
    // Async block used to run the handler and catch any Python error.
  141    145   
    let result = if handler.is_coroutine {
  142    146   
        ::tracing::trace!(name = "result", "executing python handler coroutine");
  143    147   
        let result = ::pyo3::Python::with_gil(|py| {
  144    148   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  145    149   
            let coroutine = if handler.args == 1 {
  146    150   
                pyhandler.call1((input,))?
  147    151   
            } else {
  148    152   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  149    153   
            };
  150    154   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  151    155   
        })?;
  152    156   
        result.await.and_then(|r| {
  153    157   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::ResultOutput>(py))
  154    158   
        })
  155    159   
    } else {
  156    160   
        ::tracing::trace!(name = "result", "executing python handler function");
  157    161   
        ::pyo3::Python::with_gil(|py| {
  158    162   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  159    163   
            let output = if handler.args == 1 {
  160    164   
                pyhandler.call1((input,))?
  161    165   
            } else {
  162    166   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  163    167   
            };
  164    168   
            output.extract::<crate::output::ResultOutput>()
  165    169   
        })
  166    170   
    };
  167    171   
    // Catch and record a Python traceback.
  168    172   
    result.map_err(|e| {
  169    173   
        let rich_py_err =
  170    174   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  171    175   
                e.clone_ref(py)
  172    176   
            }));
  173    177   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  174    178   
        e.into()
  175    179   
    })
  176    180   
}
  177    181   
         182  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  178    183   
/// Python handler for operation `ErrCollisions`.
  179    184   
pub(crate) async fn err_collisions(
  180    185   
    input: crate::input::ErrCollisionsInput,
  181    186   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  182    187   
    handler: ::aws_smithy_http_server_python::PyHandler,
  183    188   
) -> std::result::Result<crate::output::ErrCollisionsOutput, crate::error::ErrCollisionsError> {
  184    189   
    // Async block used to run the handler and catch any Python error.
  185    190   
    let result = if handler.is_coroutine {
  186    191   
        ::tracing::trace!(
  187    192   
            name = "err_collisions",
  188    193   
            "executing python handler coroutine"
  189    194   
        );
  190    195   
        let result = ::pyo3::Python::with_gil(|py| {
  191    196   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  192    197   
            let coroutine = if handler.args == 1 {
  193    198   
                pyhandler.call1((input,))?
  194    199   
            } else {
  195    200   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  196    201   
            };
  197    202   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  198    203   
        })?;
  199    204   
        result.await.and_then(|r| {
  200    205   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::ErrCollisionsOutput>(py))
  201    206   
        })
  202    207   
    } else {
  203    208   
        ::tracing::trace!(name = "err_collisions", "executing python handler function");
  204    209   
        ::pyo3::Python::with_gil(|py| {
  205    210   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  206    211   
            let output = if handler.args == 1 {
  207    212   
                pyhandler.call1((input,))?
  208    213   
            } else {
  209    214   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  210    215   
            };
  211    216   
            output.extract::<crate::output::ErrCollisionsOutput>()
  212    217   
        })
  213    218   
    };
  214    219   
    // Catch and record a Python traceback.
  215    220   
    result.map_err(|e| {
  216    221   
        let rich_py_err =
  217    222   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  218    223   
                e.clone_ref(py)
  219    224   
            }));
  220    225   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  221    226   
        e.into()
  222    227   
    })
  223    228   
}
  224    229   
         230  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  225    231   
/// Python handler for operation `StructureNamePunning`.
  226    232   
pub(crate) async fn structure_name_punning(
  227    233   
    input: crate::input::StructureNamePunningInput,
  228    234   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  229    235   
    handler: ::aws_smithy_http_server_python::PyHandler,
  230    236   
) -> std::result::Result<
  231    237   
    crate::output::StructureNamePunningOutput,
  232    238   
    crate::error::StructureNamePunningError,
  233    239   
> {
  234    240   
    // Async block used to run the handler and catch any Python error.
  235    241   
    let result = if handler.is_coroutine {
  236    242   
        ::tracing::trace!(
  237    243   
            name = "structure_name_punning",
  238    244   
            "executing python handler coroutine"
  239    245   
        );
  240    246   
        let result = ::pyo3::Python::with_gil(|py| {
  241    247   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  242    248   
            let coroutine = if handler.args == 1 {
  243    249   
                pyhandler.call1((input,))?
  244    250   
            } else {
  245    251   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  246    252   
            };
  247    253   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  248    254   
        })?;
  249    255   
        result.await.and_then(|r| {
  250    256   
            ::pyo3::Python::with_gil(|py| {
  251    257   
                r.extract::<crate::output::StructureNamePunningOutput>(py)
  252    258   
            })
  253    259   
        })
  254    260   
    } else {
  255    261   
        ::tracing::trace!(
  256    262   
            name = "structure_name_punning",
  257    263   
            "executing python handler function"
  258    264   
        );
  259    265   
        ::pyo3::Python::with_gil(|py| {
  260    266   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  261    267   
            let output = if handler.args == 1 {
  262    268   
                pyhandler.call1((input,))?
  263    269   
            } else {
  264    270   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  265    271   
            };
  266    272   
            output.extract::<crate::output::StructureNamePunningOutput>()
  267    273   
        })
  268    274   
    };
  269    275   
    // Catch and record a Python traceback.
  270    276   
    result.map_err(|e| {
  271    277   
        let rich_py_err =
  272    278   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  273    279   
                e.clone_ref(py)
  274    280   
            }));
  275    281   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  276    282   
        e.into()
  277    283   
    })
  278    284   
}
  279    285   
         286  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  280    287   
/// Python handler for operation `ReservedWordsAsMembers`.
  281    288   
pub(crate) async fn reserved_words_as_members(
  282    289   
    input: crate::input::ReservedWordsAsMembersInput,
  283    290   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  284    291   
    handler: ::aws_smithy_http_server_python::PyHandler,
  285    292   
) -> std::result::Result<
  286    293   
    crate::output::ReservedWordsAsMembersOutput,
  287    294   
    crate::error::ReservedWordsAsMembersError,
  288    295   
> {
  289    296   
    // Async block used to run the handler and catch any Python error.

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/python_server_application.rs

@@ -1,1 +259,284 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* PythonApplicationGenerator.kt:386 */
    2      3   
#[allow(clippy::tabs_in_doc_comments)]
    3      4   
/// Main Python application, used to register operations and context and start multiple
    4      5   
/// workers on the same shared socket.
    5      6   
///
    6      7   
/// Operations can be registered using the application object as a decorator (`@app.operation_name`).
    7      8   
///
    8      9   
/// Here's a full example to get you started:
    9     10   
///
   10     11   
/// ```python
          12  +
/* PythonApplicationGenerator.kt:399 */
   11     13   
/// from naming_test_ops import input
   12     14   
/// from naming_test_ops import output
          15  +
/* PythonApplicationGenerator.kt:406 */
   13     16   
/// from naming_test_ops import error
          17  +
/* PythonApplicationGenerator.kt:408 */
   14     18   
/// from naming_test_ops import middleware
   15     19   
/// from naming_test_ops import App
   16     20   
///
   17     21   
/// @dataclass
   18     22   
/// class Context:
   19     23   
///     counter: int = 0
   20     24   
///
   21     25   
/// app = App()
   22     26   
/// app.context(Context())
   23     27   
///
   24     28   
/// @app.request_middleware
   25     29   
/// def request_middleware(request: middleware::Request):
   26     30   
///     if request.get_header("x-amzn-id") != "secret":
   27     31   
///         raise middleware.MiddlewareException("Unsupported `x-amz-id` header", 401)
   28     32   
///
          33  +
/* PythonApplicationGenerator.kt:441 */
   29     34   
/// @app.err_collisions
   30     35   
/// def err_collisions(input: input::ErrCollisionsInput, ctx: Context) -> output::ErrCollisionsOutput:
   31     36   
///     raise NotImplementedError
   32     37   
///
   33     38   
/// @app.match
   34     39   
/// def match(input: input::MatchInput, ctx: Context) -> output::MatchOutput:
   35     40   
///     raise NotImplementedError
   36     41   
///
   37     42   
/// @app.option
   38     43   
/// def option(input: input::OptionInput, ctx: Context) -> output::OptionOutput:
   39     44   
///     raise NotImplementedError
   40     45   
///
   41     46   
/// @app.reserved_words_as_members
   42     47   
/// def reserved_words_as_members(input: input::ReservedWordsAsMembersInput, ctx: Context) -> output::ReservedWordsAsMembersOutput:
   43     48   
///     raise NotImplementedError
   44     49   
///
   45     50   
/// @app.result
   46     51   
/// def result(input: input::ResultInput, ctx: Context) -> output::ResultOutput:
   47     52   
///     raise NotImplementedError
   48     53   
///
   49     54   
/// @app.rpc_echo
   50     55   
/// def rpc_echo(input: input::RpcEchoInput, ctx: Context) -> output::RpcEchoOutput:
   51     56   
///     raise NotImplementedError
   52     57   
///
   53     58   
/// @app.structure_name_punning
   54     59   
/// def structure_name_punning(input: input::StructureNamePunningInput, ctx: Context) -> output::StructureNamePunningOutput:
   55     60   
///     raise NotImplementedError
          61  +
/* PythonApplicationGenerator.kt:428 */
   56     62   
///
   57     63   
/// app.run()
   58     64   
/// ```
   59     65   
///
   60     66   
/// Any of operations above can be written as well prepending the `async` keyword and
   61     67   
/// the Python application will automatically handle it and schedule it on the event loop for you.
          68  +
/* PythonApplicationGenerator.kt:112 */
   62     69   
#[::pyo3::pyclass]
   63     70   
#[derive(Debug)]
   64     71   
/// :generic Ctx:
   65     72   
/// :extends typing.Generic\[Ctx\]:
   66     73   
/// :rtype None:
   67     74   
pub struct App {
   68     75   
    handlers: ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler>,
   69     76   
    middlewares: Vec<::aws_smithy_http_server_python::PyMiddlewareHandler>,
   70     77   
    context: Option<::pyo3::PyObject>,
   71     78   
    workers: ::parking_lot::Mutex<Vec<::pyo3::PyObject>>,
   72     79   
}
          80  +
/* PythonApplicationGenerator.kt:149 */
   73     81   
impl Default for App {
   74     82   
    fn default() -> Self {
   75     83   
        Self {
   76     84   
            handlers: Default::default(),
   77     85   
            middlewares: vec![],
   78     86   
            context: None,
   79     87   
            workers: ::parking_lot::Mutex::new(vec![]),
   80     88   
        }
   81     89   
    }
   82     90   
}
          91  +
/* PythonApplicationGenerator.kt:131 */
   83     92   
impl Clone for App {
   84     93   
    fn clone(&self) -> Self {
   85     94   
        Self {
   86     95   
            handlers: self.handlers.clone(),
   87     96   
            middlewares: self.middlewares.clone(),
   88     97   
            context: self.context.clone(),
   89     98   
            workers: ::parking_lot::Mutex::new(vec![]),
   90     99   
        }
   91    100   
    }
   92    101   
}
         102  +
/* PythonApplicationGenerator.kt:168 */
   93    103   
impl ::aws_smithy_http_server_python::PyApp for App {
         104  +
    /* PythonApplicationGenerator.kt:174 */
   94    105   
    fn workers(&self) -> &::parking_lot::Mutex<Vec<::pyo3::PyObject>> {
   95    106   
        &self.workers
   96    107   
    }
   97    108   
    fn context(&self) -> &Option<::pyo3::PyObject> {
   98    109   
        &self.context
   99    110   
    }
  100    111   
    fn handlers(
  101    112   
        &mut self,
  102    113   
    ) -> &mut ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler> {
  103    114   
        &mut self.handlers
  104    115   
    }
         116  +
    /* PythonApplicationGenerator.kt:189 */
  105    117   
    fn build_service(
  106    118   
        &mut self,
  107    119   
        event_loop: &::pyo3::PyAny,
  108    120   
    ) -> ::pyo3::PyResult<
  109    121   
        ::tower::util::BoxCloneService<
  110    122   
            ::http::Request<::aws_smithy_http_server::body::Body>,
  111    123   
            ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  112    124   
            std::convert::Infallible,
  113    125   
        >,
  114    126   
    > {
         127  +
        /* PythonApplicationGenerator.kt:201 */
  115    128   
        let builder = crate::service::Config::builder_without_plugins();
         129  +
        /* PythonApplicationGenerator.kt:209 */
  116    130   
        let err_collisions_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  117    131   
        let handler = self
  118    132   
            .handlers
  119    133   
            .get("err_collisions")
  120    134   
            .expect("Python handler for operation `err_collisions` not found")
  121    135   
            .clone();
  122    136   
        let builder = builder.err_collisions(move |input, state| {
  123    137   
            ::pyo3_asyncio::tokio::scope(
  124    138   
                err_collisions_locals.clone(),
  125    139   
                crate::python_operation_adaptor::err_collisions(input, state, handler.clone()),
  126    140   
            )
  127    141   
        });
         142  +
        /* PythonApplicationGenerator.kt:209 */
  128    143   
        let r#match_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  129    144   
        let handler = self
  130    145   
            .handlers
  131    146   
            .get("r#match")
  132    147   
            .expect("Python handler for operation `r#match` not found")
  133    148   
            .clone();
  134    149   
        let builder = builder.r#match(move |input, state| {
  135    150   
            ::pyo3_asyncio::tokio::scope(
  136    151   
                r#match_locals.clone(),
  137    152   
                crate::python_operation_adaptor::r#match(input, state, handler.clone()),
  138    153   
            )
  139    154   
        });
         155  +
        /* PythonApplicationGenerator.kt:209 */
  140    156   
        let option_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  141    157   
        let handler = self
  142    158   
            .handlers
  143    159   
            .get("option")
  144    160   
            .expect("Python handler for operation `option` not found")
  145    161   
            .clone();
  146    162   
        let builder = builder.option(move |input, state| {
  147    163   
            ::pyo3_asyncio::tokio::scope(
  148    164   
                option_locals.clone(),
  149    165   
                crate::python_operation_adaptor::option(input, state, handler.clone()),
  150    166   
            )
  151    167   
        });
         168  +
        /* PythonApplicationGenerator.kt:209 */
  152    169   
        let reserved_words_as_members_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  153    170   
        let handler = self
  154    171   
            .handlers
  155    172   
            .get("reserved_words_as_members")
  156    173   
            .expect("Python handler for operation `reserved_words_as_members` not found")
  157    174   
            .clone();
  158    175   
        let builder = builder.reserved_words_as_members(move |input, state| {
  159    176   
            ::pyo3_asyncio::tokio::scope(
  160    177   
                reserved_words_as_members_locals.clone(),
  161    178   
                crate::python_operation_adaptor::reserved_words_as_members(
  162    179   
                    input,
  163    180   
                    state,
  164    181   
                    handler.clone(),
  165    182   
                ),
  166    183   
            )
  167    184   
        });
         185  +
        /* PythonApplicationGenerator.kt:209 */
  168    186   
        let result_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  169    187   
        let handler = self
  170    188   
            .handlers
  171    189   
            .get("result")
  172    190   
            .expect("Python handler for operation `result` not found")
  173    191   
            .clone();
  174    192   
        let builder = builder.result(move |input, state| {
  175    193   
            ::pyo3_asyncio::tokio::scope(
  176    194   
                result_locals.clone(),
  177    195   
                crate::python_operation_adaptor::result(input, state, handler.clone()),
  178    196   
            )
  179    197   
        });
         198  +
        /* PythonApplicationGenerator.kt:209 */
  180    199   
        let rpc_echo_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  181    200   
        let handler = self
  182    201   
            .handlers
  183    202   
            .get("rpc_echo")
  184    203   
            .expect("Python handler for operation `rpc_echo` not found")
  185    204   
            .clone();
  186    205   
        let builder = builder.rpc_echo(move |input, state| {
  187    206   
            ::pyo3_asyncio::tokio::scope(
  188    207   
                rpc_echo_locals.clone(),
  189    208   
                crate::python_operation_adaptor::rpc_echo(input, state, handler.clone()),
  190    209   
            )
  191    210   
        });
         211  +
        /* PythonApplicationGenerator.kt:209 */
  192    212   
        let structure_name_punning_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  193    213   
        let handler = self
  194    214   
            .handlers
  195    215   
            .get("structure_name_punning")
  196    216   
            .expect("Python handler for operation `structure_name_punning` not found")
  197    217   
            .clone();
  198    218   
        let builder = builder.structure_name_punning(move |input, state| {
  199    219   
            ::pyo3_asyncio::tokio::scope(
  200    220   
                structure_name_punning_locals.clone(),
  201    221   
                crate::python_operation_adaptor::structure_name_punning(
  202    222   
                    input,
  203    223   
                    state,
  204    224   
                    handler.clone(),
  205    225   
                ),
  206    226   
            )
  207    227   
        });
         228  +
        /* PythonApplicationGenerator.kt:220 */
  208    229   
        let mut service = ::tower::util::BoxCloneService::new(builder.build().expect("one or more operations do not have a registered handler; this is a bug in the Python code generator, please file a bug report under https://github.com/smithy-lang/smithy-rs/issues"));
  209    230   
  210    231   
        {
  211    232   
            use ::tower::Layer;
  212    233   
            ::tracing::trace!("adding middlewares to rust python router");
  213    234   
            let mut middlewares = self.middlewares.clone();
  214    235   
            // Reverse the middlewares, so they run with same order as they defined
  215    236   
            middlewares.reverse();
  216    237   
            for handler in middlewares {
  217    238   
                ::tracing::trace!(name = &handler.name, "adding python middleware");
  218    239   
                let locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  219    240   
                let layer = ::aws_smithy_http_server_python::PyMiddlewareLayer::<
  220    241   
                    ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1,
  221    242   
                >::new(handler, locals);
  222    243   
                service = ::tower::util::BoxCloneService::new(layer.layer(service));
  223    244   
            }
  224    245   
        }
  225    246   
        Ok(service)
         247  +
        /* PythonApplicationGenerator.kt:189 */
  226    248   
    }
         249  +
    /* PythonApplicationGenerator.kt:168 */
  227    250   
}
         251  +
/* PythonApplicationGenerator.kt:247 */
  228    252   
#[::pyo3::pymethods]
  229    253   
impl App {
         254  +
    /* PythonApplicationGenerator.kt:260 */
  230    255   
    /// Create a new [App].
  231    256   
    #[new]
  232    257   
    pub fn new() -> Self {
  233    258   
        Self::default()
  234    259   
    }
  235    260   
  236    261   
    /// Register a context object that will be shared between handlers.
  237    262   
    ///
  238    263   
    /// :param context Ctx:
  239    264   
    /// :rtype None:
@@ -282,307 +394,427 @@
  302    327   
        py: pyo3::Python,
  303    328   
        socket: &pyo3::PyCell<::aws_smithy_http_server_python::PySocket>,
  304    329   
        worker_number: isize,
  305    330   
        tls: Option<::aws_smithy_http_server_python::tls::PyTlsConfig>,
  306    331   
    ) -> pyo3::PyResult<()> {
  307    332   
        use ::aws_smithy_http_server_python::PyApp;
  308    333   
        let event_loop = self.configure_python_event_loop(py)?;
  309    334   
        let service = self.build_and_configure_service(py, event_loop)?;
  310    335   
        self.start_hyper_worker(py, socket, event_loop, service, worker_number, tls)
  311    336   
    }
         337  +
    /* PythonApplicationGenerator.kt:366 */
  312    338   
    /// Method to register `err_collisions` Python implementation inside the handlers map.
  313    339   
    /// It can be used as a function decorator in Python.
  314    340   
    ///
  315    341   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.ErrCollisionsInput, Ctx\], typing.Union\[naming_test_ops.output.ErrCollisionsOutput, typing.Awaitable\[naming_test_ops.output.ErrCollisionsOutput\]\]\], typing.Callable\[\[naming_test_ops.input.ErrCollisionsInput\], typing.Union\[naming_test_ops.output.ErrCollisionsOutput, typing.Awaitable\[naming_test_ops.output.ErrCollisionsOutput\]\]\]\]:
  316    342   
    /// :rtype None:
  317    343   
    #[pyo3(text_signature = "($self, func)")]
  318    344   
    pub fn err_collisions(
  319    345   
        &mut self,
  320    346   
        py: ::pyo3::Python,
  321    347   
        func: ::pyo3::PyObject,
  322    348   
    ) -> ::pyo3::PyResult<()> {
  323    349   
        use ::aws_smithy_http_server_python::PyApp;
  324    350   
        self.register_operation(py, "err_collisions", func)
  325    351   
    }
         352  +
    /* PythonApplicationGenerator.kt:366 */
  326    353   
    /// Method to register `r#match` Python implementation inside the handlers map.
  327    354   
    /// It can be used as a function decorator in Python.
  328    355   
    ///
  329    356   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.MatchInput, Ctx\], typing.Union\[naming_test_ops.output.MatchOutput, typing.Awaitable\[naming_test_ops.output.MatchOutput\]\]\], typing.Callable\[\[naming_test_ops.input.MatchInput\], typing.Union\[naming_test_ops.output.MatchOutput, typing.Awaitable\[naming_test_ops.output.MatchOutput\]\]\]\]:
  330    357   
    /// :rtype None:
  331    358   
    #[pyo3(text_signature = "($self, func)")]
  332    359   
    pub fn r#match(&mut self, py: ::pyo3::Python, func: ::pyo3::PyObject) -> ::pyo3::PyResult<()> {
  333    360   
        use ::aws_smithy_http_server_python::PyApp;
  334    361   
        self.register_operation(py, "r#match", func)
  335    362   
    }
         363  +
    /* PythonApplicationGenerator.kt:366 */
  336    364   
    /// Method to register `option` Python implementation inside the handlers map.
  337    365   
    /// It can be used as a function decorator in Python.
  338    366   
    ///
  339    367   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.OptionInput, Ctx\], typing.Union\[naming_test_ops.output.OptionOutput, typing.Awaitable\[naming_test_ops.output.OptionOutput\]\]\], typing.Callable\[\[naming_test_ops.input.OptionInput\], typing.Union\[naming_test_ops.output.OptionOutput, typing.Awaitable\[naming_test_ops.output.OptionOutput\]\]\]\]:
  340    368   
    /// :rtype None:
  341    369   
    #[pyo3(text_signature = "($self, func)")]
  342    370   
    pub fn option(&mut self, py: ::pyo3::Python, func: ::pyo3::PyObject) -> ::pyo3::PyResult<()> {
  343    371   
        use ::aws_smithy_http_server_python::PyApp;
  344    372   
        self.register_operation(py, "option", func)
  345    373   
    }
         374  +
    /* PythonApplicationGenerator.kt:366 */
  346    375   
    /// Method to register `reserved_words_as_members` Python implementation inside the handlers map.
  347    376   
    /// It can be used as a function decorator in Python.
  348    377   
    ///
  349    378   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.ReservedWordsAsMembersInput, Ctx\], typing.Union\[naming_test_ops.output.ReservedWordsAsMembersOutput, typing.Awaitable\[naming_test_ops.output.ReservedWordsAsMembersOutput\]\]\], typing.Callable\[\[naming_test_ops.input.ReservedWordsAsMembersInput\], typing.Union\[naming_test_ops.output.ReservedWordsAsMembersOutput, typing.Awaitable\[naming_test_ops.output.ReservedWordsAsMembersOutput\]\]\]\]:
  350    379   
    /// :rtype None:
  351    380   
    #[pyo3(text_signature = "($self, func)")]
  352    381   
    pub fn reserved_words_as_members(
  353    382   
        &mut self,
  354    383   
        py: ::pyo3::Python,
  355    384   
        func: ::pyo3::PyObject,
  356    385   
    ) -> ::pyo3::PyResult<()> {
  357    386   
        use ::aws_smithy_http_server_python::PyApp;
  358    387   
        self.register_operation(py, "reserved_words_as_members", func)
  359    388   
    }
         389  +
    /* PythonApplicationGenerator.kt:366 */
  360    390   
    /// Method to register `result` Python implementation inside the handlers map.
  361    391   
    /// It can be used as a function decorator in Python.
  362    392   
    ///
  363    393   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.ResultInput, Ctx\], typing.Union\[naming_test_ops.output.ResultOutput, typing.Awaitable\[naming_test_ops.output.ResultOutput\]\]\], typing.Callable\[\[naming_test_ops.input.ResultInput\], typing.Union\[naming_test_ops.output.ResultOutput, typing.Awaitable\[naming_test_ops.output.ResultOutput\]\]\]\]:
  364    394   
    /// :rtype None:
  365    395   
    #[pyo3(text_signature = "($self, func)")]
  366    396   
    pub fn result(&mut self, py: ::pyo3::Python, func: ::pyo3::PyObject) -> ::pyo3::PyResult<()> {
  367    397   
        use ::aws_smithy_http_server_python::PyApp;
  368    398   
        self.register_operation(py, "result", func)
  369    399   
    }
         400  +
    /* PythonApplicationGenerator.kt:366 */
  370    401   
    /// Method to register `rpc_echo` Python implementation inside the handlers map.
  371    402   
    /// It can be used as a function decorator in Python.
  372    403   
    ///
  373    404   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.RPCEchoInput, Ctx\], typing.Union\[naming_test_ops.output.RPCEchoOutput, typing.Awaitable\[naming_test_ops.output.RPCEchoOutput\]\]\], typing.Callable\[\[naming_test_ops.input.RPCEchoInput\], typing.Union\[naming_test_ops.output.RPCEchoOutput, typing.Awaitable\[naming_test_ops.output.RPCEchoOutput\]\]\]\]:
  374    405   
    /// :rtype None:
  375    406   
    #[pyo3(text_signature = "($self, func)")]
  376    407   
    pub fn rpc_echo(&mut self, py: ::pyo3::Python, func: ::pyo3::PyObject) -> ::pyo3::PyResult<()> {
  377    408   
        use ::aws_smithy_http_server_python::PyApp;
  378    409   
        self.register_operation(py, "rpc_echo", func)
  379    410   
    }
         411  +
    /* PythonApplicationGenerator.kt:366 */
  380    412   
    /// Method to register `structure_name_punning` Python implementation inside the handlers map.
  381    413   
    /// It can be used as a function decorator in Python.
  382    414   
    ///
  383    415   
    /// :param func typing.Union\[typing.Callable\[\[naming_test_ops.input.StructureNamePunningInput, Ctx\], typing.Union\[naming_test_ops.output.StructureNamePunningOutput, typing.Awaitable\[naming_test_ops.output.StructureNamePunningOutput\]\]\], typing.Callable\[\[naming_test_ops.input.StructureNamePunningInput\], typing.Union\[naming_test_ops.output.StructureNamePunningOutput, typing.Awaitable\[naming_test_ops.output.StructureNamePunningOutput\]\]\]\]:
  384    416   
    /// :rtype None:
  385    417   
    #[pyo3(text_signature = "($self, func)")]
  386    418   
    pub fn structure_name_punning(
  387    419   
        &mut self,
  388    420   
        py: ::pyo3::Python,
  389    421   
        func: ::pyo3::PyObject,
  390    422   
    ) -> ::pyo3::PyResult<()> {
  391    423   
        use ::aws_smithy_http_server_python::PyApp;
  392    424   
        self.register_operation(py, "structure_name_punning", func)
  393    425   
    }
         426  +
    /* PythonApplicationGenerator.kt:247 */
  394    427   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/service.rs

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerServiceGenerator.kt:795 */
    2      3   
/// The service builder for [`Config`].
    3      4   
///
    4      5   
/// Constructed via [`Config::builder`].
    5      6   
pub struct ConfigBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    err_collisions: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    r#match: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    option: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    reserved_words_as_members: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    result: Option<::aws_smithy_http_server::routing::Route<Body>>,
   11     12   
    rpc_echo: Option<::aws_smithy_http_server::routing::Route<Body>>,
@@ -1572,1573 +1631,1633 @@
 1592   1593   
impl<S> ::aws_smithy_http_server::service::ServiceShape for Config<S> {
 1593   1594   
    const ID: ::aws_smithy_http_server::shape_id::ShapeId =
 1594   1595   
        ::aws_smithy_http_server::shape_id::ShapeId::new("crate#Config", "crate", "Config");
 1595   1596   
 1596   1597   
    const VERSION: Option<&'static str> = Some("2006-03-01");
 1597   1598   
 1598   1599   
    type Protocol = ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1;
 1599   1600   
 1600   1601   
    type Operations = Operation;
 1601   1602   
}
        1603  +
/* ServiceConfigGenerator.kt:178 */
 1602   1604   
/// Configuration for the [`Config`]. This is the central place where to register and
 1603   1605   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 1604   1606   
///
 1605   1607   
/// ```rust,no_run
 1606   1608   
/// # use naming_test_ops::ConfigConfig;
 1607   1609   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 1608   1610   
/// # use ::tower::layer::util::Identity;
 1609   1611   
/// # let authentication_plugin = IdentityPlugin;
 1610   1612   
/// # let authorization_plugin = IdentityPlugin;
 1611   1613   
/// # let server_request_id_provider_layer = Identity::new();
@@ -1687,1689 +1746,1749 @@
 1707   1709   
 1708   1710   
    /// Build the configuration.
 1709   1711   
    pub fn build(self) -> super::ConfigConfig<L, H, M> {
 1710   1712   
        super::ConfigConfig {
 1711   1713   
            layers: self.layers,
 1712   1714   
            http_plugins: self.http_plugins,
 1713   1715   
            model_plugins: self.model_plugins,
 1714   1716   
        }
 1715   1717   
    }
 1716   1718   
}
        1719  +
/* ScopeMacroGenerator.kt:81 */
 1717   1720   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 1718   1721   
///
 1719   1722   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 1720   1723   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 1721   1724   
///
 1722   1725   
/// # Example
 1723   1726   
///
 1724   1727   
/// ```rust
 1725   1728   
/// scope! {
 1726   1729   
///     /// Includes [`ErrCollisions`], excluding all other operations.

tmp-codegen-diff/codegen-server-test-python/naming_test_ops/rust-server-codegen-python/src/types.rs

@@ -1,1 +0,7 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* SmithyTypesPubUseExtra.kt:66 */
    2      3   
pub use ::aws_smithy_types::date_time::Format as DateTimeFormat;
           4  +
/* ServerRequiredCustomizations.kt:69 */
    3      5   
pub use ::aws_smithy_types::error::display::DisplayErrorContext;
    4      6   
pub use ::aws_smithy_types::Blob;
    5         -
pub use ::aws_smithy_types::DateTime;
           7  +
/* SmithyTypesPubUseExtra.kt:69 */ pub use ::aws_smithy_types::DateTime;

tmp-codegen-diff/codegen-server-test-python/naming_test_structs/rust-server-codegen-python/Cargo.toml

@@ -6,6 +58,58 @@
   26     26   
version = "0.2.9"
   27     27   
[dependencies.hyper]
   28     28   
version = "0.14.26"
   29     29   
[dependencies.mime]
   30     30   
version = "0.3"
   31     31   
[dependencies.parking_lot]
   32     32   
version = "0.12"
   33     33   
[dependencies.pin-project-lite]
   34     34   
version = "0.2"
   35     35   
[dependencies.pyo3]
   36         -
version = "0.18"
          36  +
version = "0.20"
   37     37   
[dependencies.pyo3-asyncio]
   38         -
version = "0.18"
          38  +
version = "0.20"
   39     39   
features = ["attributes", "tokio-runtime"]
   40     40   
[dependencies.tower]
   41     41   
version = "0.4"
   42     42   
[dependencies.tracing]
   43     43   
version = "0.1"
   44     44   
[dev-dependencies.hyper]
   45     45   
version = "0.14.12"
   46     46   
[dev-dependencies.tokio]
   47     47   
version = "1.23.1"
   48     48   
[features]

tmp-codegen-diff/codegen-server-test-python/naming_test_structs/rust-server-codegen-python/src/error.rs

@@ -1,1 +161,280 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerOperationErrorGenerator.kt:63 */
    2      3   
/// Error type for the `Structs` operation.
           4  +
/* ServerOperationErrorGenerator.kt:64 */
    3      5   
/// Each variant represents an error that can occur for the `Structs` operation.
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(::std::fmt::Debug)]
    5         -
pub enum StructsError {
           8  +
pub /* ServerOperationErrorGenerator.kt:66 */ enum StructsError {
           9  +
    /* ServerOperationErrorGenerator.kt:68 */
    6     10   
    #[allow(missing_docs)] // documentation missing in model
          11  +
    /* ServerOperationErrorGenerator.kt:71 */
    7     12   
    InternalServerError(crate::error::InternalServerError),
          13  +
    /* ServerOperationErrorGenerator.kt:66 */
    8     14   
}
          15  +
/* ServerOperationErrorGenerator.kt:75 */
    9     16   
impl ::std::fmt::Display for StructsError {
          17  +
    /* ServerOperationErrorGenerator.kt:76 */
   10     18   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          19  +
        /* ServerOperationErrorGenerator.kt:139 */
   11     20   
        match &self {
   12         -
            StructsError::InternalServerError(_inner) => _inner.fmt(f),
          21  +
            /* ServerOperationErrorGenerator.kt:142 */
          22  +
            StructsError::InternalServerError(_inner) =>
          23  +
            /* ServerOperationErrorGenerator.kt:78 */
          24  +
            {
          25  +
                _inner.fmt(f)
          26  +
            }
          27  +
            /* ServerOperationErrorGenerator.kt:139 */
   13     28   
        }
          29  +
        /* ServerOperationErrorGenerator.kt:76 */
   14     30   
    }
          31  +
    /* ServerOperationErrorGenerator.kt:75 */
   15     32   
}
          33  +
/* ServerOperationErrorGenerator.kt:83 */
   16     34   
impl StructsError {
          35  +
    /* ServerOperationErrorGenerator.kt:87 */
   17     36   
    /// Returns `true` if the error kind is `StructsError::InternalServerError`.
          37  +
    /* ServerOperationErrorGenerator.kt:88 */
   18     38   
    pub fn is_internal_server_error(&self) -> bool {
          39  +
        /* ServerOperationErrorGenerator.kt:89 */
   19     40   
        matches!(&self, StructsError::InternalServerError(_))
          41  +
        /* ServerOperationErrorGenerator.kt:88 */
   20     42   
    }
          43  +
    /* ServerOperationErrorGenerator.kt:92 */
   21     44   
    /// Returns the error name string by matching the correct variant.
          45  +
    /* ServerOperationErrorGenerator.kt:93 */
   22     46   
    pub fn name(&self) -> &'static str {
          47  +
        /* ServerOperationErrorGenerator.kt:139 */
   23     48   
        match &self {
   24         -
            StructsError::InternalServerError(_inner) => _inner.name(),
          49  +
            /* ServerOperationErrorGenerator.kt:142 */
          50  +
            StructsError::InternalServerError(_inner) =>
          51  +
            /* ServerOperationErrorGenerator.kt:95 */
          52  +
            {
          53  +
                _inner.name()
   25     54   
            }
          55  +
            /* ServerOperationErrorGenerator.kt:139 */
   26     56   
        }
          57  +
        /* ServerOperationErrorGenerator.kt:93 */
          58  +
    }
          59  +
    /* ServerOperationErrorGenerator.kt:83 */
   27     60   
}
          61  +
/* ServerOperationErrorGenerator.kt:100 */
   28     62   
impl ::std::error::Error for StructsError {
          63  +
    /* ServerOperationErrorGenerator.kt:101 */
   29     64   
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
          65  +
        /* ServerOperationErrorGenerator.kt:139 */
   30     66   
        match &self {
   31         -
            StructsError::InternalServerError(_inner) => Some(_inner),
          67  +
            /* ServerOperationErrorGenerator.kt:142 */
          68  +
            StructsError::InternalServerError(_inner) =>
          69  +
            /* ServerOperationErrorGenerator.kt:103 */
          70  +
            {
          71  +
                Some(_inner)
          72  +
            }
          73  +
            /* ServerOperationErrorGenerator.kt:139 */
   32     74   
        }
          75  +
        /* ServerOperationErrorGenerator.kt:101 */
   33     76   
    }
          77  +
    /* ServerOperationErrorGenerator.kt:100 */
   34     78   
}
          79  +
/* ServerOperationErrorGenerator.kt:110 */
   35     80   
impl ::std::convert::From<crate::error::InternalServerError> for crate::error::StructsError {
          81  +
    /* ServerOperationErrorGenerator.kt:111 */
   36     82   
    fn from(variant: crate::error::InternalServerError) -> crate::error::StructsError {
          83  +
        /* ServerOperationErrorGenerator.kt:112 */
   37     84   
        Self::InternalServerError(variant)
          85  +
        /* ServerOperationErrorGenerator.kt:111 */
   38     86   
    }
          87  +
    /* ServerOperationErrorGenerator.kt:110 */
   39     88   
}
   40     89   
          90  +
/* PythonServerOperationErrorGenerator.kt:38 */
   41     91   
impl ::std::convert::From<::pyo3::PyErr> for crate::error::StructsError {
   42     92   
    fn from(variant: ::pyo3::PyErr) -> crate::error::StructsError {
   43     93   
        ::pyo3::Python::with_gil(|py| {
   44     94   
            let error = variant.value(py);
   45     95   
   46     96   
            crate::error::InternalServerError {
   47     97   
                message: error.to_string(),
   48     98   
            }
   49     99   
            .into()
   50    100   
        })
   51    101   
    }
   52    102   
}
   53    103   
         104  +
/* RustType.kt:516 */
   54    105   
#[::pyo3::pyclass(extends = ::pyo3::exceptions::PyException)]
         106  +
/* PythonServerStructureGenerator.kt:63 */
   55    107   
/// :param message str:
   56    108   
/// :rtype None:
         109  +
/* StructureGenerator.kt:197 */
   57    110   
#[allow(missing_docs)] // documentation missing in model
         111  +
/* RustType.kt:516 */
   58    112   
#[derive(
   59    113   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   60    114   
)]
   61         -
pub struct InternalServerError {
         115  +
pub /* StructureGenerator.kt:201 */ struct InternalServerError {
         116  +
    /* RustType.kt:516 */
   62    117   
    #[pyo3(get, set)]
         118  +
    /* PythonServerStructureGenerator.kt:80 */
   63    119   
    /// :type str:
         120  +
    /* StructureGenerator.kt:231 */
   64    121   
    #[allow(missing_docs)] // documentation missing in model
   65    122   
    pub message: ::std::string::String,
         123  +
    /* StructureGenerator.kt:201 */
   66    124   
}
         125  +
/* RustType.kt:516 */
   67    126   
#[allow(clippy::new_without_default)]
         127  +
/* RustType.kt:516 */
   68    128   
#[allow(clippy::too_many_arguments)]
         129  +
/* RustType.kt:516 */
   69    130   
#[::pyo3::pymethods]
         131  +
/* PythonServerStructureGenerator.kt:88 */
   70    132   
impl InternalServerError {
   71    133   
    #[new]
   72    134   
    pub fn new(message: ::std::string::String) -> Self {
   73    135   
        Self { message }
   74    136   
    }
   75    137   
    fn __repr__(&self) -> String {
   76    138   
        format!("{self:?}")
   77    139   
    }
   78    140   
    fn __str__(&self) -> String {
   79    141   
        format!("{self:?}")
   80    142   
    }
   81    143   
}
         144  +
/* ErrorImplGenerator.kt:99 */
   82    145   
impl InternalServerError {
         146  +
    /* ErrorImplGenerator.kt:128 */
   83    147   
    /// Returns the error message.
   84    148   
    pub fn message(&self) -> &str {
   85    149   
        &self.message
   86    150   
    }
         151  +
    /* ErrorImplGenerator.kt:141 */
   87    152   
    #[doc(hidden)]
   88    153   
    /// Returns the error name.
   89    154   
    pub fn name(&self) -> &'static str {
   90    155   
        "InternalServerError"
   91    156   
    }
         157  +
    /* ErrorImplGenerator.kt:99 */
   92    158   
}
         159  +
/* ErrorImplGenerator.kt:153 */
   93    160   
impl ::std::fmt::Display for InternalServerError {
         161  +
    /* ErrorImplGenerator.kt:154 */
   94    162   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         163  +
        /* ErrorImplGenerator.kt:161 */
   95    164   
        ::std::write!(f, "InternalServerError")?;
         165  +
        /* ErrorImplGenerator.kt:166 */
   96    166   
        {
         167  +
            /* ErrorImplGenerator.kt:167 */
   97    168   
            ::std::write!(f, ": {}", &self.message)?;
         169  +
            /* ErrorImplGenerator.kt:166 */
   98    170   
        }
         171  +
        /* ErrorImplGenerator.kt:171 */
   99    172   
        Ok(())
         173  +
        /* ErrorImplGenerator.kt:154 */
  100    174   
    }
         175  +
    /* ErrorImplGenerator.kt:153 */
  101    176   
}
         177  +
/* ErrorImplGenerator.kt:175 */
  102    178   
impl ::std::error::Error for InternalServerError {}
         179  +
/* ServerCodegenVisitor.kt:370 */
  103    180   
impl InternalServerError {
  104         -
    /// Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         181  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         182  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  105    183   
    pub fn builder() -> crate::error::internal_server_error::Builder {
         184  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
  106    185   
        crate::error::internal_server_error::Builder::default()
         186  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  107    187   
    }
         188  +
    /* ServerCodegenVisitor.kt:370 */
  108    189   
}
  109         -
/// See [`InternalServerError`](crate::error::InternalServerError).
         190  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`InternalServerError`](crate::error::InternalServerError).
  110    191   
pub mod internal_server_error {
  111    192   
         193  +
    /* RustType.kt:516 */
  112    194   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  113         -
    /// Holds one variant for each of the ways the builder can fail.
  114         -
         195  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
         196  +
    /* ServerBuilderConstraintViolations.kt:75 */
  115    197   
    #[allow(clippy::enum_variant_names)]
  116    198   
    pub enum ConstraintViolation {
  117         -
        /// `message` was not provided but it is required when building `InternalServerError`.
         199  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`message` was not provided but it is required when building `InternalServerError`.
         200  +
        /* ServerBuilderConstraintViolations.kt:143 */
  118    201   
        MissingMessage,
         202  +
        /* ServerBuilderConstraintViolations.kt:75 */
  119    203   
    }
         204  +
    /* ServerBuilderConstraintViolations.kt:117 */
  120    205   
    impl ::std::fmt::Display for ConstraintViolation {
         206  +
        /* ServerBuilderConstraintViolations.kt:118 */
  121    207   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         208  +
            /* ServerBuilderConstraintViolations.kt:119 */
  122    209   
            match self {
  123         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
  124         -
            }
         210  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
         211  +
            /* ServerBuilderConstraintViolations.kt:119 */}
         212  +
            /* ServerBuilderConstraintViolations.kt:118 */
  125    213   
        }
         214  +
        /* ServerBuilderConstraintViolations.kt:117 */
  126    215   
    }
         216  +
    /* ServerBuilderConstraintViolations.kt:84 */
  127    217   
    impl ::std::error::Error for ConstraintViolation {}
         218  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:254 */
  128    219   
    impl ::std::convert::TryFrom<Builder> for crate::error::InternalServerError {
  129    220   
        type Error = ConstraintViolation;
  130    221   
  131    222   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  132    223   
            builder.build()
  133    224   
        }
  134    225   
    }
  135         -
    /// A builder for [`InternalServerError`](crate::error::InternalServerError).
         226  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`InternalServerError`](crate::error::InternalServerError).
         227  +
    /* RustType.kt:516 */
  136    228   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         229  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  137    230   
    pub struct Builder {
         231  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  138    232   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         233  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  139    234   
    }
         235  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  140    236   
    impl Builder {
         237  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  141    238   
        #[allow(missing_docs)] // documentation missing in model
         239  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  142    240   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  143         -
            self.message = Some(input);
         241  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         242  +
            self.message =
         243  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */Some(
         244  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         245  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */)
         246  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  144    247   
            self
         248  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  145    249   
        }
  146         -
        /// Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
  147         -
        ///
         250  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
         251  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:152 */
  148    252   
        /// The builder fails to construct a [`InternalServerError`](crate::error::InternalServerError) if you do not provide a value for all non-`Option`al members.
  149    253   
        ///
         254  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
  150    255   
        pub fn build(self) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  151    256   
            self.build_enforcing_required_and_enum_traits()
  152    257   
        }
         258  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  153    259   
        fn build_enforcing_required_and_enum_traits(
  154    260   
            self,
  155    261   
        ) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  156         -
            Ok(crate::error::InternalServerError {
  157         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  158         -
            })
         262  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         263  +
            Ok(
         264  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         265  +
                crate::error::InternalServerError {
         266  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
         267  +
                    message: self
         268  +
                        .message
         269  +
                        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:202 */
         270  +
                        .ok_or(ConstraintViolation::MissingMessage)?,
         271  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         272  +
                }, /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         273  +
            )
         274  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  159    275   
        }
         276  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  160    277   
    }
         278  +
         279  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  161    280   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_structs/rust-server-codegen-python/src/input.rs

@@ -1,1 +243,392 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[::pyo3::pyclass]
           4  +
/* PythonServerStructureGenerator.kt:63 */
    3      5   
/// :param result typing.Optional\[naming_test_structs.model.Result\]:
    4      6   
/// :param result_list typing.Optional\[typing.List\[naming_test_structs.model.Result\]\]:
    5      7   
/// :param option typing.Optional\[naming_test_structs.model.Option\]:
    6      8   
/// :param option_list typing.Optional\[typing.List\[naming_test_structs.model.Result\]\]:
    7      9   
/// :param something_else typing.Optional\[naming_test_structs.model.SomethingElse\]:
    8     10   
/// :rtype None:
          11  +
/* StructureGenerator.kt:197 */
    9     12   
#[allow(missing_docs)] // documentation missing in model
          13  +
/* RustType.kt:516 */
   10     14   
#[derive(
   11     15   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   12     16   
)]
   13         -
pub struct StructsInput {
          17  +
pub /* StructureGenerator.kt:201 */ struct StructsInput {
          18  +
    /* RustType.kt:516 */
   14     19   
    #[pyo3(get, set)]
          20  +
    /* PythonServerStructureGenerator.kt:80 */
   15     21   
    /// :type typing.Optional\[naming_test_structs.model.Result\]:
          22  +
    /* StructureGenerator.kt:231 */
   16     23   
    #[allow(missing_docs)] // documentation missing in model
   17     24   
    pub result: ::std::option::Option<crate::model::Result>,
          25  +
    /* RustType.kt:516 */
   18     26   
    #[pyo3(get, set)]
          27  +
    /* PythonServerStructureGenerator.kt:80 */
   19     28   
    /// :type typing.Optional\[typing.List\[naming_test_structs.model.Result\]\]:
          29  +
    /* StructureGenerator.kt:231 */
   20     30   
    #[allow(missing_docs)] // documentation missing in model
   21     31   
    pub result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          32  +
    /* RustType.kt:516 */
   22     33   
    #[pyo3(get, set)]
          34  +
    /* PythonServerStructureGenerator.kt:80 */
   23     35   
    /// :type typing.Optional\[naming_test_structs.model.Option\]:
          36  +
    /* StructureGenerator.kt:231 */
   24     37   
    #[allow(missing_docs)] // documentation missing in model
   25     38   
    pub option: ::std::option::Option<crate::model::Option>,
          39  +
    /* RustType.kt:516 */
   26     40   
    #[pyo3(get, set)]
          41  +
    /* PythonServerStructureGenerator.kt:80 */
   27     42   
    /// :type typing.Optional\[typing.List\[naming_test_structs.model.Result\]\]:
          43  +
    /* StructureGenerator.kt:231 */
   28     44   
    #[allow(missing_docs)] // documentation missing in model
   29     45   
    pub option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
          46  +
    /* RustType.kt:516 */
   30     47   
    #[pyo3(get, set)]
          48  +
    /* PythonServerStructureGenerator.kt:80 */
   31     49   
    /// :type typing.Optional\[naming_test_structs.model.SomethingElse\]:
          50  +
    /* StructureGenerator.kt:231 */
   32     51   
    #[allow(missing_docs)] // documentation missing in model
   33     52   
    pub something_else: ::std::option::Option<crate::model::SomethingElse>,
          53  +
    /* StructureGenerator.kt:201 */
   34     54   
}
          55  +
/* StructureGenerator.kt:135 */
   35     56   
impl StructsInput {
          57  +
    /* StructureGenerator.kt:231 */
   36     58   
    #[allow(missing_docs)] // documentation missing in model
          59  +
                           /* StructureGenerator.kt:166 */
   37     60   
    pub fn result(&self) -> ::std::option::Option<&crate::model::Result> {
          61  +
        /* StructureGenerator.kt:170 */
   38     62   
        self.result.as_ref()
          63  +
        /* StructureGenerator.kt:166 */
   39     64   
    }
          65  +
    /* StructureGenerator.kt:231 */
   40     66   
    #[allow(missing_docs)] // documentation missing in model
          67  +
                           /* StructureGenerator.kt:166 */
   41     68   
    pub fn result_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          69  +
        /* StructureGenerator.kt:169 */
   42     70   
        self.result_list.as_deref()
          71  +
        /* StructureGenerator.kt:166 */
   43     72   
    }
          73  +
    /* StructureGenerator.kt:231 */
   44     74   
    #[allow(missing_docs)] // documentation missing in model
          75  +
                           /* StructureGenerator.kt:166 */
   45     76   
    pub fn option(&self) -> ::std::option::Option<&crate::model::Option> {
          77  +
        /* StructureGenerator.kt:170 */
   46     78   
        self.option.as_ref()
          79  +
        /* StructureGenerator.kt:166 */
   47     80   
    }
          81  +
    /* StructureGenerator.kt:231 */
   48     82   
    #[allow(missing_docs)] // documentation missing in model
          83  +
                           /* StructureGenerator.kt:166 */
   49     84   
    pub fn option_list(&self) -> ::std::option::Option<&[crate::model::Result]> {
          85  +
        /* StructureGenerator.kt:169 */
   50     86   
        self.option_list.as_deref()
          87  +
        /* StructureGenerator.kt:166 */
   51     88   
    }
          89  +
    /* StructureGenerator.kt:231 */
   52     90   
    #[allow(missing_docs)] // documentation missing in model
          91  +
                           /* StructureGenerator.kt:166 */
   53     92   
    pub fn something_else(&self) -> ::std::option::Option<&crate::model::SomethingElse> {
          93  +
        /* StructureGenerator.kt:170 */
   54     94   
        self.something_else.as_ref()
          95  +
        /* StructureGenerator.kt:166 */
   55     96   
    }
          97  +
    /* StructureGenerator.kt:135 */
   56     98   
}
          99  +
/* RustType.kt:516 */
   57    100   
#[allow(clippy::new_without_default)]
         101  +
/* RustType.kt:516 */
   58    102   
#[allow(clippy::too_many_arguments)]
         103  +
/* RustType.kt:516 */
   59    104   
#[::pyo3::pymethods]
         105  +
/* PythonServerStructureGenerator.kt:88 */
   60    106   
impl StructsInput {
   61    107   
    #[new]
   62    108   
    pub fn new(
   63    109   
        result: ::std::option::Option<crate::model::Result>,
   64    110   
        result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
   65    111   
        option: ::std::option::Option<crate::model::Option>,
   66    112   
        option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
   67    113   
        something_else: ::std::option::Option<crate::model::SomethingElse>,
   68    114   
    ) -> Self {
   69    115   
        Self {
   70    116   
            result,
   71    117   
            result_list,
   72    118   
            option,
   73    119   
            option_list,
   74    120   
            something_else,
   75    121   
        }
   76    122   
    }
   77    123   
    fn __repr__(&self) -> String {
   78    124   
        format!("{self:?}")
   79    125   
    }
   80    126   
    fn __str__(&self) -> String {
   81    127   
        format!("{self:?}")
   82    128   
    }
   83    129   
}
         130  +
/* PythonServerStructureGenerator.kt:111 */
   84    131   
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<StructsInput> {
   85    132   
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
   86    133   
        ob.extract::<StructsInput>().map(Box::new)
   87    134   
    }
   88    135   
}
   89    136   
   90    137   
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<StructsInput> {
   91    138   
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
   92    139   
        (*self).into_py(py)
   93    140   
    }
   94    141   
}
         142  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
   95    143   
impl crate::constrained::Constrained for crate::input::StructsInput {
   96    144   
    type Unconstrained = crate::input::structs_input_internal::Builder;
   97    145   
}
         146  +
/* ServerCodegenVisitor.kt:370 */
   98    147   
impl StructsInput {
   99         -
    /// Creates a new builder-style object to manufacture [`StructsInput`](crate::input::StructsInput).
         148  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`StructsInput`](crate::input::StructsInput).
         149  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  100    150   
    pub fn builder() -> crate::input::structs_input::Builder {
         151  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
  101    152   
        crate::input::structs_input::Builder::default()
         153  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
  102    154   
    }
         155  +
    /* ServerCodegenVisitor.kt:370 */
  103    156   
}
  104         -
/// See [`StructsInput`](crate::input::StructsInput).
         157  +
/// /* ServerBuilderGenerator.kt:171 */See [`StructsInput`](crate::input::StructsInput).
  105    158   
pub(crate) mod structs_input_internal {
  106    159   
         160  +
    /* ServerBuilderGenerator.kt:461 */
  107    161   
    impl ::std::convert::From<Builder> for crate::input::StructsInput {
  108    162   
        fn from(builder: Builder) -> Self {
  109    163   
            builder.build()
  110    164   
        }
  111    165   
    }
  112         -
    /// A builder for [`StructsInput`](crate::input::StructsInput).
         166  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`StructsInput`](crate::input::StructsInput).
         167  +
    /* RustType.kt:516 */
  113    168   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         169  +
    /* ServerBuilderGenerator.kt:211 */
  114    170   
    pub(crate) struct Builder {
         171  +
        /* ServerBuilderGenerator.kt:308 */
  115    172   
        pub(crate) result: ::std::option::Option<crate::model::Result>,
         173  +
        /* ServerBuilderGenerator.kt:308 */
  116    174   
        pub(crate) result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         175  +
        /* ServerBuilderGenerator.kt:308 */
  117    176   
        pub(crate) option: ::std::option::Option<crate::model::Option>,
         177  +
        /* ServerBuilderGenerator.kt:308 */
  118    178   
        pub(crate) option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         179  +
        /* ServerBuilderGenerator.kt:308 */
  119    180   
        pub(crate) something_else: ::std::option::Option<crate::model::SomethingElse>,
         181  +
        /* ServerBuilderGenerator.kt:211 */
  120    182   
    }
         183  +
    /* ServerBuilderGenerator.kt:215 */
  121    184   
    impl Builder {
         185  +
        /* ServerBuilderGenerator.kt:426 */
  122    186   
        #[allow(missing_docs)] // documentation missing in model
         187  +
                               /* ServerBuilderGenerator.kt:428 */
  123    188   
        pub(crate) fn set_result(
  124    189   
            mut self,
  125    190   
            input: Option<impl ::std::convert::Into<crate::model::Result>>,
  126    191   
        ) -> Self {
         192  +
            /* ServerBuilderGenerator.kt:429 */
  127    193   
            self.result = input.map(|v| v.into());
  128    194   
            self
         195  +
            /* ServerBuilderGenerator.kt:428 */
  129    196   
        }
         197  +
        /* ServerBuilderGenerator.kt:426 */
  130    198   
        #[allow(missing_docs)] // documentation missing in model
         199  +
                               /* ServerBuilderGenerator.kt:428 */
  131    200   
        pub(crate) fn set_result_list(
  132    201   
            mut self,
  133    202   
            input: Option<impl ::std::convert::Into<::std::vec::Vec<crate::model::Result>>>,
  134    203   
        ) -> Self {
         204  +
            /* ServerBuilderGenerator.kt:429 */
  135    205   
            self.result_list = input.map(|v| v.into());
  136    206   
            self
         207  +
            /* ServerBuilderGenerator.kt:428 */
  137    208   
        }
         209  +
        /* ServerBuilderGenerator.kt:426 */
  138    210   
        #[allow(missing_docs)] // documentation missing in model
         211  +
                               /* ServerBuilderGenerator.kt:428 */
  139    212   
        pub(crate) fn set_option(
  140    213   
            mut self,
  141    214   
            input: Option<impl ::std::convert::Into<crate::model::Option>>,
  142    215   
        ) -> Self {
         216  +
            /* ServerBuilderGenerator.kt:429 */
  143    217   
            self.option = input.map(|v| v.into());
  144    218   
            self
         219  +
            /* ServerBuilderGenerator.kt:428 */
  145    220   
        }
         221  +
        /* ServerBuilderGenerator.kt:426 */
  146    222   
        #[allow(missing_docs)] // documentation missing in model
         223  +
                               /* ServerBuilderGenerator.kt:428 */
  147    224   
        pub(crate) fn set_option_list(
  148    225   
            mut self,
  149    226   
            input: Option<impl ::std::convert::Into<::std::vec::Vec<crate::model::Result>>>,
  150    227   
        ) -> Self {
         228  +
            /* ServerBuilderGenerator.kt:429 */
  151    229   
            self.option_list = input.map(|v| v.into());
  152    230   
            self
         231  +
            /* ServerBuilderGenerator.kt:428 */
  153    232   
        }
         233  +
        /* ServerBuilderGenerator.kt:426 */
  154    234   
        #[allow(missing_docs)] // documentation missing in model
         235  +
                               /* ServerBuilderGenerator.kt:428 */
  155    236   
        pub(crate) fn set_something_else(
  156    237   
            mut self,
  157    238   
            input: Option<impl ::std::convert::Into<crate::model::SomethingElse>>,
  158    239   
        ) -> Self {
         240  +
            /* ServerBuilderGenerator.kt:429 */
  159    241   
            self.something_else = input.map(|v| v.into());
  160    242   
            self
         243  +
            /* ServerBuilderGenerator.kt:428 */
  161    244   
        }
  162         -
        /// Consumes the builder and constructs a [`StructsInput`](crate::input::StructsInput).
         245  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`StructsInput`](crate::input::StructsInput).
         246  +
        /* ServerBuilderGenerator.kt:271 */
  163    247   
        pub fn build(self) -> crate::input::StructsInput {
  164    248   
            self.build_enforcing_all_constraints()
  165    249   
        }
         250  +
        /* ServerBuilderGenerator.kt:283 */
  166    251   
        fn build_enforcing_all_constraints(self) -> crate::input::StructsInput {
         252  +
            /* ServerBuilderGenerator.kt:542 */
  167    253   
            crate::input::StructsInput {
         254  +
                /* ServerBuilderGenerator.kt:546 */
  168    255   
                result: self.result,
         256  +
                /* ServerBuilderGenerator.kt:546 */
  169    257   
                result_list: self.result_list,
         258  +
                /* ServerBuilderGenerator.kt:546 */
  170    259   
                option: self.option,
         260  +
                /* ServerBuilderGenerator.kt:546 */
  171    261   
                option_list: self.option_list,
         262  +
                /* ServerBuilderGenerator.kt:546 */
  172    263   
                something_else: self.something_else,
         264  +
                /* ServerBuilderGenerator.kt:542 */
  173    265   
            }
         266  +
            /* ServerBuilderGenerator.kt:283 */
  174    267   
        }
         268  +
        /* ServerBuilderGenerator.kt:215 */
  175    269   
    }
         270  +
         271  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  176    272   
}
  177         -
/// See [`StructsInput`](crate::input::StructsInput).
         273  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`StructsInput`](crate::input::StructsInput).
  178    274   
pub mod structs_input {
  179    275   
         276  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
  180    277   
    impl ::std::convert::From<Builder> for crate::input::StructsInput {
  181    278   
        fn from(builder: Builder) -> Self {
  182    279   
            builder.build()
  183    280   
        }
  184    281   
    }
  185         -
    /// A builder for [`StructsInput`](crate::input::StructsInput).
         282  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`StructsInput`](crate::input::StructsInput).
         283  +
    /* RustType.kt:516 */
  186    284   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         285  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  187    286   
    pub struct Builder {
         287  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  188    288   
        pub(crate) result: ::std::option::Option<crate::model::Result>,
         289  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  189    290   
        pub(crate) result_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         291  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  190    292   
        pub(crate) option: ::std::option::Option<crate::model::Option>,
         293  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  191    294   
        pub(crate) option_list: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
         295  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  192    296   
        pub(crate) something_else: ::std::option::Option<crate::model::SomethingElse>,
         297  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  193    298   
    }
         299  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  194    300   
    impl Builder {
         301  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  195    302   
        #[allow(missing_docs)] // documentation missing in model
         303  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  196    304   
        pub fn result(mut self, input: ::std::option::Option<crate::model::Result>) -> Self {
  197         -
            self.result = input;
         305  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         306  +
            self.result =
         307  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         308  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  198    309   
            self
         310  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  199    311   
        }
         312  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  200    313   
        #[allow(missing_docs)] // documentation missing in model
         314  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  201    315   
        pub fn result_list(
  202    316   
            mut self,
  203    317   
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
  204    318   
        ) -> Self {
  205         -
            self.result_list = input;
         319  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         320  +
            self.result_list =
         321  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         322  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  206    323   
            self
         324  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  207    325   
        }
         326  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  208    327   
        #[allow(missing_docs)] // documentation missing in model
         328  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  209    329   
        pub fn option(mut self, input: ::std::option::Option<crate::model::Option>) -> Self {
  210         -
            self.option = input;
         330  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         331  +
            self.option =
         332  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         333  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  211    334   
            self
         335  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  212    336   
        }
         337  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  213    338   
        #[allow(missing_docs)] // documentation missing in model
         339  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  214    340   
        pub fn option_list(
  215    341   
            mut self,
  216    342   
            input: ::std::option::Option<::std::vec::Vec<crate::model::Result>>,
  217    343   
        ) -> Self {
  218         -
            self.option_list = input;
         344  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         345  +
            self.option_list =
         346  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         347  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  219    348   
            self
         349  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  220    350   
        }
         351  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  221    352   
        #[allow(missing_docs)] // documentation missing in model
         353  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  222    354   
        pub fn something_else(
  223    355   
            mut self,
  224    356   
            input: ::std::option::Option<crate::model::SomethingElse>,
  225    357   
        ) -> Self {
  226         -
            self.something_else = input;
         358  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         359  +
            self.something_else =
         360  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         361  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  227    362   
            self
         363  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  228    364   
        }
  229         -
        /// Consumes the builder and constructs a [`StructsInput`](crate::input::StructsInput).
         365  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`StructsInput`](crate::input::StructsInput).
         366  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
  230    367   
        pub fn build(self) -> crate::input::StructsInput {
  231    368   
            self.build_enforcing_required_and_enum_traits()
  232    369   
        }
         370  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  233    371   
        fn build_enforcing_required_and_enum_traits(self) -> crate::input::StructsInput {
         372  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
  234    373   
            crate::input::StructsInput {
         374  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  235    375   
                result: self.result,
         376  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  236    377   
                result_list: self.result_list,
         378  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  237    379   
                option: self.option,
         380  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  238    381   
                option_list: self.option_list,
         382  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  239    383   
                something_else: self.something_else,
         384  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
  240    385   
            }
         386  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  241    387   
        }
         388  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  242    389   
    }
         390  +
         391  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  243    392   
}

tmp-codegen-diff/codegen-server-test-python/naming_test_structs/rust-server-codegen-python/src/lib.rs

@@ -1,1 +52,53 @@
   13     13   
#![allow(clippy::result_large_err)]
   14     14   
#![allow(clippy::unnecessary_map_on_constructor)]
   15     15   
#![allow(rustdoc::bare_urls)]
   16     16   
#![allow(rustdoc::redundant_explicit_links)]
   17     17   
#![allow(rustdoc::invalid_html_tags)]
   18     18   
#![forbid(unsafe_code)]
   19     19   
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
   20     20   
//! Confounds model generation machinery with lots of problematic names
   21     21   
   22     22   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
          23  +
/* ServerRootGenerator.kt:65 */
   23     24   
//! A fast and customizable Rust implementation of the NamingObstacleCourseStructs Smithy service.
   24     25   
//!
   25     26   
//! # Using NamingObstacleCourseStructs
   26     27   
//!
   27     28   
//! The primary entrypoint is [`NamingObstacleCourseStructs`]: it satisfies the [`Service<http::Request, Response = http::Response>`](::tower::Service)
   28     29   
//! trait and therefore can be handed to a [`hyper` server](https://github.com/hyperium/hyper) via [`NamingObstacleCourseStructs::into_make_service`]
   29     30   
//! or used in AWS Lambda
   30     31   
#![cfg_attr(
   31     32   
    feature = "aws-lambda",
   32     33   
    doc = " via [`LambdaHandler`](crate::server::routing::LambdaHandler)."
@@ -167,168 +259,272 @@
  187    188   
//! }
  188    189   
//!
  189    190   
//! ```
  190    191   
//!
  191    192   
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
  192    193   
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
  193    194   
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
  194    195   
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
  195    196   
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  196    197   
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         198  +
/* ServerRootGenerator.kt:261 */
  197    199   
pub use crate::service::{
  198    200   
    MissingOperationsError, NamingObstacleCourseStructs, NamingObstacleCourseStructsBuilder,
  199    201   
    NamingObstacleCourseStructsConfig, NamingObstacleCourseStructsConfigBuilder,
  200    202   
};
  201    203   
  202         -
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         204  +
/// /* ServerRustModule.kt:55 */Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  203    205   
pub mod server {
  204    206   
    // Re-export all types from the `aws-smithy-http-server` crate.
  205    207   
    pub use ::aws_smithy_http_server::*;
         208  +
         209  +
    /* CodegenDelegator.kt:200 */
  206    210   
}
  207    211   
         212  +
/* CrateVersionCustomization.kt:23 */
  208    213   
/// Crate version number.
  209    214   
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
  210    215   
  211         -
/// All error types that operations can return. Documentation on these types is copied from the model.
         216  +
/// /* ServerRustModule.kt:55 */All error types that operations can return. Documentation on these types is copied from the model.
  212    217   
pub mod error;
  213    218   
  214         -
/// Input structures for operations. Documentation on these types is copied from the model.
         219  +
/// /* ServerRustModule.kt:55 */Input structures for operations. Documentation on these types is copied from the model.
  215    220   
pub mod input;
  216    221   
  217         -
/// Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
         222  +
/// /* ServerRustModule.kt:55 */Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
  218    223   
pub mod model;
  219    224   
  220         -
/// All operations that this crate can perform.
         225  +
/// /* ServerRustModule.kt:55 */All operations that this crate can perform.
  221    226   
pub mod operation;
  222    227   
         228  +
/* ServerRustModule.kt:79 */
  223    229   
/// A collection of types representing each operation defined in the service closure.
  224    230   
///
  225    231   
/// The [plugin system](::aws_smithy_http_server::plugin) makes use of these
  226    232   
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
  227    233   
/// parameterize [`Plugin`](::aws_smithy_http_server::plugin::Plugin) implementations. Their traits, such as
  228    234   
/// [`OperationShape`](::aws_smithy_http_server::operation::OperationShape), can be used to provide
  229    235   
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
  230    236   
pub mod operation_shape;
  231    237   
  232         -
/// Output structures for operations. Documentation on these types is copied from the model.
         238  +
/// /* ServerRustModule.kt:55 */Output structures for operations. Documentation on these types is copied from the model.
  233    239   
pub mod output;
  234    240   
  235         -
/// Export PyO3 symbols in the shared library
         241  +
/// /* PythonServerRustModule.kt:23 */Export PyO3 symbols in the shared library
  236    242   
pub mod python_module_export;
  237    243   
  238         -
/// Operation adapters that delegate to Python handlers.
         244  +
/// /* PythonServerRustModule.kt:23 */Operation adapters that delegate to Python handlers.
  239    245   
pub mod python_operation_adaptor;
  240    246   
  241         -
/// Python server and application implementation.
         247  +
/// /* PythonServerRustModule.kt:23 */Python server and application implementation.
  242    248   
pub mod python_server_application;
  243    249   
         250  +
/* RustModule.kt:172 */
  244    251   
mod service;
  245    252   
  246         -
/// Data primitives referenced by other data types.
         253  +
/// /* ServerRustModule.kt:55 */Data primitives referenced by other data types.
  247    254   
pub mod types;
  248    255   
  249         -
/// Constrained types for constrained shapes.
         256  +
/// /* ServerRustModule.kt:55 */Constrained types for constrained shapes.
         257  +
/* RustModule.kt:172 */
  250    258   
mod constrained;
  251    259   
  252    260   
pub(crate) mod protocol_serde;
  253    261   
  254         -
/// Re-exported Python types from supporting crates.
         262  +
/// /* PythonServerCodegenDecorator.kt:57 */Re-exported Python types from supporting crates.
         263  +
/* PythonServerCodegenDecorator.kt:58 */
  255    264   
pub mod python_types {
         265  +
    /* PythonServerCodegenDecorator.kt:59 */
  256    266   
    pub use ::aws_smithy_http_server_python::types::Blob;
         267  +
    /* PythonServerCodegenDecorator.kt:60 */
  257    268   
    pub use ::aws_smithy_http_server_python::types::DateTime;
         269  +
    /* PythonServerCodegenDecorator.kt:61 */
  258    270   
    pub use ::aws_smithy_http_server_python::types::Document;
         271  +
    /* PythonServerCodegenDecorator.kt:58 */
  259    272   
}