Server Test Python

Server Test Python

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943

Files changed:

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

@@ -1,1 +542,553 @@
    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 `QueryPrecedence`.
    3      4   
pub(crate) async fn query_precedence(
    4      5   
    input: crate::input::QueryPrecedenceInput,
    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::QueryPrecedenceOutput, crate::error::QueryPrecedenceError> {
    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!(
   11     12   
            name = "query_precedence",
   12     13   
            "executing python handler coroutine"
   13     14   
        );
   14     15   
        let result = ::pyo3::Python::with_gil(|py| {
   15     16   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   16     17   
            let coroutine = if handler.args == 1 {
   17     18   
                pyhandler.call1((input,))?
   18     19   
            } else {
   19     20   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   20     21   
            };
   21     22   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   22     23   
        })?;
   23     24   
        result.await.and_then(|r| {
   24     25   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::QueryPrecedenceOutput>(py))
   25     26   
        })
   26     27   
    } else {
   27     28   
        ::tracing::trace!(
   28     29   
            name = "query_precedence",
   29     30   
            "executing python handler function"
   30     31   
        );
   31     32   
        ::pyo3::Python::with_gil(|py| {
   32     33   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   33     34   
            let output = if handler.args == 1 {
   34     35   
                pyhandler.call1((input,))?
   35     36   
            } else {
   36     37   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   37     38   
            };
   38     39   
            output.extract::<crate::output::QueryPrecedenceOutput>()
   39     40   
        })
   40     41   
    };
   41     42   
    // Catch and record a Python traceback.
   42     43   
    result.map_err(|e| {
   43     44   
        let rich_py_err =
   44     45   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
   45     46   
                e.clone_ref(py)
   46     47   
            }));
   47     48   
        ::tracing::error!(error = ?rich_py_err, "handler error");
   48     49   
        e.into()
   49     50   
    })
   50     51   
}
   51     52   
          53  +
/* PythonServerOperationHandlerGenerator.kt:61 */
   52     54   
/// Python handler for operation `EmptyStructWithContentOnWireOp`.
   53     55   
pub(crate) async fn empty_struct_with_content_on_wire_op(
   54     56   
    input: crate::input::EmptyStructWithContentOnWireOpInput,
   55     57   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
   56     58   
    handler: ::aws_smithy_http_server_python::PyHandler,
   57     59   
) -> std::result::Result<
   58     60   
    crate::output::EmptyStructWithContentOnWireOpOutput,
   59     61   
    crate::error::EmptyStructWithContentOnWireOpError,
   60     62   
> {
   61     63   
    // Async block used to run the handler and catch any Python error.
   62     64   
    let result = if handler.is_coroutine {
   63     65   
        ::tracing::trace!(
   64     66   
            name = "empty_struct_with_content_on_wire_op",
   65     67   
            "executing python handler coroutine"
   66     68   
        );
   67     69   
        let result = ::pyo3::Python::with_gil(|py| {
   68     70   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   69     71   
            let coroutine = if handler.args == 1 {
   70     72   
                pyhandler.call1((input,))?
   71     73   
            } else {
   72     74   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   73     75   
            };
   74     76   
            ::pyo3_asyncio::tokio::into_future(coroutine)
   75     77   
        })?;
   76     78   
        result.await.and_then(|r| {
   77     79   
            ::pyo3::Python::with_gil(|py| {
   78     80   
                r.extract::<crate::output::EmptyStructWithContentOnWireOpOutput>(py)
   79     81   
            })
   80     82   
        })
   81     83   
    } else {
   82     84   
        ::tracing::trace!(
   83     85   
            name = "empty_struct_with_content_on_wire_op",
   84     86   
            "executing python handler function"
   85     87   
        );
   86     88   
        ::pyo3::Python::with_gil(|py| {
   87     89   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
   88     90   
            let output = if handler.args == 1 {
   89     91   
                pyhandler.call1((input,))?
   90     92   
            } else {
   91     93   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
   92     94   
            };
   93     95   
            output.extract::<crate::output::EmptyStructWithContentOnWireOpOutput>()
   94     96   
        })
   95     97   
    };
   96     98   
    // Catch and record a Python traceback.
   97     99   
    result.map_err(|e| {
   98    100   
        let rich_py_err =
   99    101   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  100    102   
                e.clone_ref(py)
  101    103   
            }));
  102    104   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  103    105   
        e.into()
  104    106   
    })
  105    107   
}
  106    108   
         109  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  107    110   
/// Python handler for operation `CaseInsensitiveErrorOperation`.
  108    111   
pub(crate) async fn case_insensitive_error_operation(
  109    112   
    input: crate::input::CaseInsensitiveErrorOperationInput,
  110    113   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  111    114   
    handler: ::aws_smithy_http_server_python::PyHandler,
  112    115   
) -> std::result::Result<
  113    116   
    crate::output::CaseInsensitiveErrorOperationOutput,
  114    117   
    crate::error::CaseInsensitiveErrorOperationError,
  115    118   
> {
  116    119   
    // Async block used to run the handler and catch any Python error.
  117    120   
    let result = if handler.is_coroutine {
  118    121   
        ::tracing::trace!(
  119    122   
            name = "case_insensitive_error_operation",
  120    123   
            "executing python handler coroutine"
  121    124   
        );
  122    125   
        let result = ::pyo3::Python::with_gil(|py| {
  123    126   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  124    127   
            let coroutine = if handler.args == 1 {
  125    128   
                pyhandler.call1((input,))?
  126    129   
            } else {
  127    130   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  128    131   
            };
  129    132   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  130    133   
        })?;
  131    134   
        result.await.and_then(|r| {
  132    135   
            ::pyo3::Python::with_gil(|py| {
  133    136   
                r.extract::<crate::output::CaseInsensitiveErrorOperationOutput>(py)
  134    137   
            })
  135    138   
        })
  136    139   
    } else {
  137    140   
        ::tracing::trace!(
  138    141   
            name = "case_insensitive_error_operation",
  139    142   
            "executing python handler function"
  140    143   
        );
  141    144   
        ::pyo3::Python::with_gil(|py| {
  142    145   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  143    146   
            let output = if handler.args == 1 {
  144    147   
                pyhandler.call1((input,))?
  145    148   
            } else {
  146    149   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  147    150   
            };
  148    151   
            output.extract::<crate::output::CaseInsensitiveErrorOperationOutput>()
  149    152   
        })
  150    153   
    };
  151    154   
    // Catch and record a Python traceback.
  152    155   
    result.map_err(|e| {
  153    156   
        let rich_py_err =
  154    157   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  155    158   
                e.clone_ref(py)
  156    159   
            }));
  157    160   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  158    161   
        e.into()
  159    162   
    })
  160    163   
}
  161    164   
         165  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  162    166   
/// Python handler for operation `NullInNonSparse`.
  163    167   
pub(crate) async fn null_in_non_sparse(
  164    168   
    input: crate::input::NullInNonSparseInput,
  165    169   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  166    170   
    handler: ::aws_smithy_http_server_python::PyHandler,
  167    171   
) -> std::result::Result<crate::output::NullInNonSparseOutput, crate::error::NullInNonSparseError> {
  168    172   
    // Async block used to run the handler and catch any Python error.
  169    173   
    let result = if handler.is_coroutine {
  170    174   
        ::tracing::trace!(
  171    175   
            name = "null_in_non_sparse",
  172    176   
            "executing python handler coroutine"
  173    177   
        );
  174    178   
        let result = ::pyo3::Python::with_gil(|py| {
  175    179   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  176    180   
            let coroutine = if handler.args == 1 {
  177    181   
                pyhandler.call1((input,))?
  178    182   
            } else {
  179    183   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  180    184   
            };
  181    185   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  182    186   
        })?;
  183    187   
        result.await.and_then(|r| {
  184    188   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::NullInNonSparseOutput>(py))
  185    189   
        })
  186    190   
    } else {
  187    191   
        ::tracing::trace!(
  188    192   
            name = "null_in_non_sparse",
  189    193   
            "executing python handler function"
  190    194   
        );
  191    195   
        ::pyo3::Python::with_gil(|py| {
  192    196   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  193    197   
            let output = if handler.args == 1 {
  194    198   
                pyhandler.call1((input,))?
  195    199   
            } else {
  196    200   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  197    201   
            };
  198    202   
            output.extract::<crate::output::NullInNonSparseOutput>()
  199    203   
        })
  200    204   
    };
  201    205   
    // Catch and record a Python traceback.
  202    206   
    result.map_err(|e| {
  203    207   
        let rich_py_err =
  204    208   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  205    209   
                e.clone_ref(py)
  206    210   
            }));
  207    211   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  208    212   
        e.into()
  209    213   
    })
  210    214   
}
  211    215   
         216  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  212    217   
/// Python handler for operation `EscapedStringValues`.
  213    218   
pub(crate) async fn escaped_string_values(
  214    219   
    input: crate::input::EscapedStringValuesInput,
  215    220   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  216    221   
    handler: ::aws_smithy_http_server_python::PyHandler,
  217    222   
) -> std::result::Result<
  218    223   
    crate::output::EscapedStringValuesOutput,
  219    224   
    crate::error::EscapedStringValuesError,
  220    225   
> {
  221    226   
    // Async block used to run the handler and catch any Python error.
  222    227   
    let result = if handler.is_coroutine {
  223    228   
        ::tracing::trace!(
  224    229   
            name = "escaped_string_values",
  225    230   
            "executing python handler coroutine"
  226    231   
        );
  227    232   
        let result = ::pyo3::Python::with_gil(|py| {
  228    233   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  229    234   
            let coroutine = if handler.args == 1 {
  230    235   
                pyhandler.call1((input,))?
  231    236   
            } else {
  232    237   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  233    238   
            };
  234    239   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  235    240   
        })?;
  236    241   
        result.await.and_then(|r| {
  237    242   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::EscapedStringValuesOutput>(py))
  238    243   
        })
  239    244   
    } else {
  240    245   
        ::tracing::trace!(
  241    246   
            name = "escaped_string_values",
  242    247   
            "executing python handler function"
  243    248   
        );
  244    249   
        ::pyo3::Python::with_gil(|py| {
  245    250   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  246    251   
            let output = if handler.args == 1 {
  247    252   
                pyhandler.call1((input,))?
  248    253   
            } else {
  249    254   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  250    255   
            };
  251    256   
            output.extract::<crate::output::EscapedStringValuesOutput>()
  252    257   
        })
  253    258   
    };
  254    259   
    // Catch and record a Python traceback.
  255    260   
    result.map_err(|e| {
  256    261   
        let rich_py_err =
  257    262   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  258    263   
                e.clone_ref(py)
  259    264   
            }));
  260    265   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  261    266   
        e.into()
  262    267   
    })
  263    268   
}
  264    269   
         270  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  265    271   
/// Python handler for operation `PrimitiveIntOp`.
  266    272   
pub(crate) async fn primitive_int_op(
  267    273   
    input: crate::input::PrimitiveIntOpInput,
  268    274   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  269    275   
    handler: ::aws_smithy_http_server_python::PyHandler,
  270    276   
) -> std::result::Result<crate::output::PrimitiveIntOpOutput, crate::error::PrimitiveIntOpError> {
  271    277   
    // Async block used to run the handler and catch any Python error.
  272    278   
    let result = if handler.is_coroutine {
  273    279   
        ::tracing::trace!(
  274    280   
            name = "primitive_int_op",
  275    281   
            "executing python handler coroutine"
  276    282   
        );
  277    283   
        let result = ::pyo3::Python::with_gil(|py| {
  278    284   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  279    285   
            let coroutine = if handler.args == 1 {
  280    286   
                pyhandler.call1((input,))?
  281    287   
            } else {
  282    288   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  283    289   
            };
  284    290   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  285    291   
        })?;
  286    292   
        result.await.and_then(|r| {
  287    293   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::PrimitiveIntOpOutput>(py))
  288    294   
        })
  289    295   
    } else {
  290    296   
        ::tracing::trace!(
  291    297   
            name = "primitive_int_op",
  292    298   
            "executing python handler function"
  293    299   
        );
  294    300   
        ::pyo3::Python::with_gil(|py| {
  295    301   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  296    302   
            let output = if handler.args == 1 {
  297    303   
                pyhandler.call1((input,))?
  298    304   
            } else {
  299    305   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  300    306   
            };
  301    307   
            output.extract::<crate::output::PrimitiveIntOpOutput>()
  302    308   
        })
  303    309   
    };
  304    310   
    // Catch and record a Python traceback.
  305    311   
    result.map_err(|e| {
  306    312   
        let rich_py_err =
  307    313   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  308    314   
                e.clone_ref(py)
  309    315   
            }));
  310    316   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  311    317   
        e.into()
  312    318   
    })
  313    319   
}
  314    320   
         321  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  315    322   
/// Python handler for operation `MapWithEnumKeyOp`.
  316    323   
pub(crate) async fn map_with_enum_key_op(
  317    324   
    input: crate::input::MapWithEnumKeyOpInput,
  318    325   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  319    326   
    handler: ::aws_smithy_http_server_python::PyHandler,
  320    327   
) -> std::result::Result<crate::output::MapWithEnumKeyOpOutput, crate::error::MapWithEnumKeyOpError>
  321    328   
{
  322    329   
    // Async block used to run the handler and catch any Python error.
  323    330   
    let result = if handler.is_coroutine {
  324    331   
        ::tracing::trace!(
  325    332   
            name = "map_with_enum_key_op",
  326    333   
            "executing python handler coroutine"
  327    334   
        );
  328    335   
        let result = ::pyo3::Python::with_gil(|py| {
  329    336   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  330    337   
            let coroutine = if handler.args == 1 {
  331    338   
                pyhandler.call1((input,))?
  332    339   
            } else {
  333    340   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  334    341   
            };
  335    342   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  336    343   
        })?;
  337    344   
        result.await.and_then(|r| {
  338    345   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::MapWithEnumKeyOpOutput>(py))
  339    346   
        })
  340    347   
    } else {
  341    348   
        ::tracing::trace!(
  342    349   
            name = "map_with_enum_key_op",
  343    350   
            "executing python handler function"
  344    351   
        );
  345    352   
        ::pyo3::Python::with_gil(|py| {
  346    353   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  347    354   
            let output = if handler.args == 1 {
  348    355   
                pyhandler.call1((input,))?
  349    356   
            } else {
  350    357   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  351    358   
            };
  352    359   
            output.extract::<crate::output::MapWithEnumKeyOpOutput>()
  353    360   
        })
  354    361   
    };
  355    362   
    // Catch and record a Python traceback.
  356    363   
    result.map_err(|e| {
  357    364   
        let rich_py_err =
  358    365   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  359    366   
                e.clone_ref(py)
  360    367   
            }));
  361    368   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  362    369   
        e.into()
  363    370   
    })
  364    371   
}
  365    372   
         373  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  366    374   
/// Python handler for operation `StatusResponse`.
  367    375   
pub(crate) async fn status_response(
  368    376   
    input: crate::input::StatusResponseInput,
  369    377   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  370    378   
    handler: ::aws_smithy_http_server_python::PyHandler,
  371    379   
) -> std::result::Result<crate::output::StatusResponseOutput, crate::error::StatusResponseError> {
  372    380   
    // Async block used to run the handler and catch any Python error.
  373    381   
    let result = if handler.is_coroutine {
  374    382   
        ::tracing::trace!(
  375    383   
            name = "status_response",
  376    384   
            "executing python handler coroutine"
  377    385   
        );
  378    386   
        let result = ::pyo3::Python::with_gil(|py| {
  379    387   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  380    388   
            let coroutine = if handler.args == 1 {
  381    389   
                pyhandler.call1((input,))?
  382    390   
            } else {
  383    391   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  384    392   
            };
  385    393   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  386    394   
        })?;
  387    395   
        result.await.and_then(|r| {
  388    396   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::StatusResponseOutput>(py))
  389    397   
        })
  390    398   
    } else {
  391    399   
        ::tracing::trace!(
  392    400   
            name = "status_response",
  393    401   
            "executing python handler function"
  394    402   
        );
  395    403   
        ::pyo3::Python::with_gil(|py| {
  396    404   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  397    405   
            let output = if handler.args == 1 {
  398    406   
                pyhandler.call1((input,))?
  399    407   
            } else {
  400    408   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  401    409   
            };
  402    410   
            output.extract::<crate::output::StatusResponseOutput>()
  403    411   
        })
  404    412   
    };
  405    413   
    // Catch and record a Python traceback.
  406    414   
    result.map_err(|e| {
  407    415   
        let rich_py_err =
  408    416   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  409    417   
                e.clone_ref(py)
  410    418   
            }));
  411    419   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  412    420   
        e.into()
  413    421   
    })
  414    422   
}
  415    423   
         424  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  416    425   
/// Python handler for operation `EnumQuery`.
  417    426   
pub(crate) async fn enum_query(
  418    427   
    input: crate::input::EnumQueryInput,
  419    428   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  420    429   
    handler: ::aws_smithy_http_server_python::PyHandler,
  421    430   
) -> std::result::Result<crate::output::EnumQueryOutput, crate::error::EnumQueryError> {
  422    431   
    // Async block used to run the handler and catch any Python error.
  423    432   
    let result = if handler.is_coroutine {
  424    433   
        ::tracing::trace!(name = "enum_query", "executing python handler coroutine");
  425    434   
        let result = ::pyo3::Python::with_gil(|py| {
  426    435   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  427    436   
            let coroutine = if handler.args == 1 {
  428    437   
                pyhandler.call1((input,))?
  429    438   
            } else {
  430    439   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  431    440   
            };
  432    441   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  433    442   
        })?;
  434    443   
        result.await.and_then(|r| {
  435    444   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::EnumQueryOutput>(py))
  436    445   
        })
  437    446   
    } else {
  438    447   
        ::tracing::trace!(name = "enum_query", "executing python handler function");
  439    448   
        ::pyo3::Python::with_gil(|py| {
  440    449   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  441    450   
            let output = if handler.args == 1 {
  442    451   
                pyhandler.call1((input,))?
  443    452   
            } else {
  444    453   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  445    454   
            };
  446    455   
            output.extract::<crate::output::EnumQueryOutput>()
  447    456   
        })
  448    457   
    };
  449    458   
    // Catch and record a Python traceback.
  450    459   
    result.map_err(|e| {
  451    460   
        let rich_py_err =
  452    461   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  453    462   
                e.clone_ref(py)
  454    463   
            }));
  455    464   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  456    465   
        e.into()
  457    466   
    })
  458    467   
}
  459    468   
         469  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  460    470   
/// Python handler for operation `PrimitiveIntHeader`.
  461    471   
pub(crate) async fn primitive_int_header(
  462    472   
    input: crate::input::PrimitiveIntHeaderInput,
  463    473   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  464    474   
    handler: ::aws_smithy_http_server_python::PyHandler,
  465    475   
) -> std::result::Result<
  466    476   
    crate::output::PrimitiveIntHeaderOutput,
  467    477   
    crate::error::PrimitiveIntHeaderError,
  468    478   
> {
  469    479   
    // Async block used to run the handler and catch any Python error.
  470    480   
    let result = if handler.is_coroutine {
  471    481   
        ::tracing::trace!(
  472    482   
            name = "primitive_int_header",
  473    483   
            "executing python handler coroutine"
  474    484   
        );
  475    485   
        let result = ::pyo3::Python::with_gil(|py| {
  476    486   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  477    487   
            let coroutine = if handler.args == 1 {
  478    488   
                pyhandler.call1((input,))?
  479    489   
            } else {
  480    490   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  481    491   
            };
  482    492   
            ::pyo3_asyncio::tokio::into_future(coroutine)
  483    493   
        })?;
  484    494   
        result.await.and_then(|r| {
  485    495   
            ::pyo3::Python::with_gil(|py| r.extract::<crate::output::PrimitiveIntHeaderOutput>(py))
  486    496   
        })
  487    497   
    } else {
  488    498   
        ::tracing::trace!(
  489    499   
            name = "primitive_int_header",
  490    500   
            "executing python handler function"
  491    501   
        );
  492    502   
        ::pyo3::Python::with_gil(|py| {
  493    503   
            let pyhandler: &::pyo3::types::PyFunction = handler.extract(py)?;
  494    504   
            let output = if handler.args == 1 {
  495    505   
                pyhandler.call1((input,))?
  496    506   
            } else {
  497    507   
                pyhandler.call1((input, ::pyo3::ToPyObject::to_object(&state.0, py)))?
  498    508   
            };
  499    509   
            output.extract::<crate::output::PrimitiveIntHeaderOutput>()
  500    510   
        })
  501    511   
    };
  502    512   
    // Catch and record a Python traceback.
  503    513   
    result.map_err(|e| {
  504    514   
        let rich_py_err =
  505    515   
            ::aws_smithy_http_server_python::rich_py_err(::pyo3::Python::with_gil(|py| {
  506    516   
                e.clone_ref(py)
  507    517   
            }));
  508    518   
        ::tracing::error!(error = ?rich_py_err, "handler error");
  509    519   
        e.into()
  510    520   
    })
  511    521   
}
  512    522   
         523  +
/* PythonServerOperationHandlerGenerator.kt:61 */
  513    524   
/// Python handler for operation `StringPayload`.
  514    525   
pub(crate) async fn string_payload(
  515    526   
    input: crate::input::StringPayloadInput,
  516    527   
    state: ::aws_smithy_http_server::Extension<::aws_smithy_http_server_python::context::PyContext>,
  517    528   
    handler: ::aws_smithy_http_server_python::PyHandler,
  518    529   
) -> std::result::Result<crate::output::StringPayloadOutput, crate::error::StringPayloadError> {
  519    530   
    // Async block used to run the handler and catch any Python error.
  520    531   
    let result = if handler.is_coroutine {
  521    532   
        ::tracing::trace!(
  522    533   
            name = "string_payload",

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

@@ -1,1 +336,365 @@
    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 rest_json_extras import input
   12     14   
/// from rest_json_extras import output
          15  +
/* PythonApplicationGenerator.kt:406 */
   13     16   
/// from rest_json_extras import error
          17  +
/* PythonApplicationGenerator.kt:408 */
   14     18   
/// from rest_json_extras import middleware
   15     19   
/// from rest_json_extras 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.case_insensitive_error_operation
   30     35   
/// def case_insensitive_error_operation(input: input::CaseInsensitiveErrorOperationInput, ctx: Context) -> output::CaseInsensitiveErrorOperationOutput:
   31     36   
///     raise NotImplementedError
   32     37   
///
   33     38   
/// @app.empty_struct_with_content_on_wire_op
   34     39   
/// def empty_struct_with_content_on_wire_op(input: input::EmptyStructWithContentOnWireOpInput, ctx: Context) -> output::EmptyStructWithContentOnWireOpOutput:
   35     40   
///     raise NotImplementedError
   36     41   
///
   37     42   
/// @app.enum_query
   38     43   
/// def enum_query(input: input::EnumQueryInput, ctx: Context) -> output::EnumQueryOutput:
   39     44   
///     raise NotImplementedError
   40     45   
///
   41     46   
/// @app.escaped_string_values
   42     47   
/// def escaped_string_values(input: input::EscapedStringValuesInput, ctx: Context) -> output::EscapedStringValuesOutput:
   43     48   
///     raise NotImplementedError
   44     49   
///
   45     50   
/// @app.map_with_enum_key_op
   46     51   
/// def map_with_enum_key_op(input: input::MapWithEnumKeyOpInput, ctx: Context) -> output::MapWithEnumKeyOpOutput:
   47     52   
///     raise NotImplementedError
   48     53   
///
   49     54   
/// @app.null_in_non_sparse
   50     55   
/// def null_in_non_sparse(input: input::NullInNonSparseInput, ctx: Context) -> output::NullInNonSparseOutput:
   51     56   
///     raise NotImplementedError
   52     57   
///
   53     58   
/// @app.primitive_int_header
   54     59   
/// def primitive_int_header(input: input::PrimitiveIntHeaderInput, ctx: Context) -> output::PrimitiveIntHeaderOutput:
   55     60   
///     raise NotImplementedError
   56     61   
///
   57     62   
/// @app.primitive_int_op
   58     63   
/// def primitive_int_op(input: input::PrimitiveIntOpInput, ctx: Context) -> output::PrimitiveIntOpOutput:
   59     64   
///     raise NotImplementedError
   60     65   
///
   61     66   
/// @app.query_precedence
   62     67   
/// def query_precedence(input: input::QueryPrecedenceInput, ctx: Context) -> output::QueryPrecedenceOutput:
   63     68   
///     raise NotImplementedError
   64     69   
///
   65     70   
/// @app.status_response
   66     71   
/// def status_response(input: input::StatusResponseInput, ctx: Context) -> output::StatusResponseOutput:
   67     72   
///     raise NotImplementedError
   68     73   
///
   69     74   
/// @app.string_payload
   70     75   
/// def string_payload(input: input::StringPayloadInput, ctx: Context) -> output::StringPayloadOutput:
   71     76   
///     raise NotImplementedError
          77  +
/* PythonApplicationGenerator.kt:428 */
   72     78   
///
   73     79   
/// app.run()
   74     80   
/// ```
   75     81   
///
   76     82   
/// Any of operations above can be written as well prepending the `async` keyword and
   77     83   
/// the Python application will automatically handle it and schedule it on the event loop for you.
          84  +
/* PythonApplicationGenerator.kt:112 */
   78     85   
#[::pyo3::pyclass]
   79     86   
#[derive(Debug)]
   80     87   
/// :generic Ctx:
   81     88   
/// :extends typing.Generic\[Ctx\]:
   82     89   
/// :rtype None:
   83     90   
pub struct App {
   84     91   
    handlers: ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler>,
   85     92   
    middlewares: Vec<::aws_smithy_http_server_python::PyMiddlewareHandler>,
   86     93   
    context: Option<::pyo3::PyObject>,
   87     94   
    workers: ::parking_lot::Mutex<Vec<::pyo3::PyObject>>,
   88     95   
}
          96  +
/* PythonApplicationGenerator.kt:149 */
   89     97   
impl Default for App {
   90     98   
    fn default() -> Self {
   91     99   
        Self {
   92    100   
            handlers: Default::default(),
   93    101   
            middlewares: vec![],
   94    102   
            context: None,
   95    103   
            workers: ::parking_lot::Mutex::new(vec![]),
   96    104   
        }
   97    105   
    }
   98    106   
}
         107  +
/* PythonApplicationGenerator.kt:131 */
   99    108   
impl Clone for App {
  100    109   
    fn clone(&self) -> Self {
  101    110   
        Self {
  102    111   
            handlers: self.handlers.clone(),
  103    112   
            middlewares: self.middlewares.clone(),
  104    113   
            context: self.context.clone(),
  105    114   
            workers: ::parking_lot::Mutex::new(vec![]),
  106    115   
        }
  107    116   
    }
  108    117   
}
         118  +
/* PythonApplicationGenerator.kt:168 */
  109    119   
impl ::aws_smithy_http_server_python::PyApp for App {
         120  +
    /* PythonApplicationGenerator.kt:174 */
  110    121   
    fn workers(&self) -> &::parking_lot::Mutex<Vec<::pyo3::PyObject>> {
  111    122   
        &self.workers
  112    123   
    }
  113    124   
    fn context(&self) -> &Option<::pyo3::PyObject> {
  114    125   
        &self.context
  115    126   
    }
  116    127   
    fn handlers(
  117    128   
        &mut self,
  118    129   
    ) -> &mut ::std::collections::HashMap<String, ::aws_smithy_http_server_python::PyHandler> {
  119    130   
        &mut self.handlers
  120    131   
    }
         132  +
    /* PythonApplicationGenerator.kt:189 */
  121    133   
    fn build_service(
  122    134   
        &mut self,
  123    135   
        event_loop: &::pyo3::PyAny,
  124    136   
    ) -> ::pyo3::PyResult<
  125    137   
        ::tower::util::BoxCloneService<
  126    138   
            ::http::Request<::aws_smithy_http_server::body::Body>,
  127    139   
            ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  128    140   
            std::convert::Infallible,
  129    141   
        >,
  130    142   
    > {
         143  +
        /* PythonApplicationGenerator.kt:201 */
  131    144   
        let builder = crate::service::RestJsonExtras::builder_without_plugins();
         145  +
        /* PythonApplicationGenerator.kt:209 */
  132    146   
        let case_insensitive_error_operation_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  133    147   
        let handler = self
  134    148   
            .handlers
  135    149   
            .get("case_insensitive_error_operation")
  136    150   
            .expect("Python handler for operation `case_insensitive_error_operation` not found")
  137    151   
            .clone();
  138    152   
        let builder = builder.case_insensitive_error_operation(move |input, state| {
  139    153   
            ::pyo3_asyncio::tokio::scope(
  140    154   
                case_insensitive_error_operation_locals.clone(),
  141    155   
                crate::python_operation_adaptor::case_insensitive_error_operation(
  142    156   
                    input,
  143    157   
                    state,
  144    158   
                    handler.clone(),
  145    159   
                ),
  146    160   
            )
  147    161   
        });
         162  +
        /* PythonApplicationGenerator.kt:209 */
  148    163   
        let empty_struct_with_content_on_wire_op_locals =
  149    164   
            ::pyo3_asyncio::TaskLocals::new(event_loop);
  150    165   
        let handler = self
  151    166   
            .handlers
  152    167   
            .get("empty_struct_with_content_on_wire_op")
  153    168   
            .expect("Python handler for operation `empty_struct_with_content_on_wire_op` not found")
  154    169   
            .clone();
  155    170   
        let builder = builder.empty_struct_with_content_on_wire_op(move |input, state| {
  156    171   
            ::pyo3_asyncio::tokio::scope(
  157    172   
                empty_struct_with_content_on_wire_op_locals.clone(),
  158    173   
                crate::python_operation_adaptor::empty_struct_with_content_on_wire_op(
  159    174   
                    input,
  160    175   
                    state,
  161    176   
                    handler.clone(),
  162    177   
                ),
  163    178   
            )
  164    179   
        });
         180  +
        /* PythonApplicationGenerator.kt:209 */
  165    181   
        let enum_query_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  166    182   
        let handler = self
  167    183   
            .handlers
  168    184   
            .get("enum_query")
  169    185   
            .expect("Python handler for operation `enum_query` not found")
  170    186   
            .clone();
  171    187   
        let builder = builder.enum_query(move |input, state| {
  172    188   
            ::pyo3_asyncio::tokio::scope(
  173    189   
                enum_query_locals.clone(),
  174    190   
                crate::python_operation_adaptor::enum_query(input, state, handler.clone()),
  175    191   
            )
  176    192   
        });
         193  +
        /* PythonApplicationGenerator.kt:209 */
  177    194   
        let escaped_string_values_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  178    195   
        let handler = self
  179    196   
            .handlers
  180    197   
            .get("escaped_string_values")
  181    198   
            .expect("Python handler for operation `escaped_string_values` not found")
  182    199   
            .clone();
  183    200   
        let builder = builder.escaped_string_values(move |input, state| {
  184    201   
            ::pyo3_asyncio::tokio::scope(
  185    202   
                escaped_string_values_locals.clone(),
  186    203   
                crate::python_operation_adaptor::escaped_string_values(
  187    204   
                    input,
  188    205   
                    state,
  189    206   
                    handler.clone(),
  190    207   
                ),
  191    208   
            )
  192    209   
        });
         210  +
        /* PythonApplicationGenerator.kt:209 */
  193    211   
        let map_with_enum_key_op_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  194    212   
        let handler = self
  195    213   
            .handlers
  196    214   
            .get("map_with_enum_key_op")
  197    215   
            .expect("Python handler for operation `map_with_enum_key_op` not found")
  198    216   
            .clone();
  199    217   
        let builder = builder.map_with_enum_key_op(move |input, state| {
  200    218   
            ::pyo3_asyncio::tokio::scope(
  201    219   
                map_with_enum_key_op_locals.clone(),
  202    220   
                crate::python_operation_adaptor::map_with_enum_key_op(
  203    221   
                    input,
  204    222   
                    state,
  205    223   
                    handler.clone(),
  206    224   
                ),
  207    225   
            )
  208    226   
        });
         227  +
        /* PythonApplicationGenerator.kt:209 */
  209    228   
        let null_in_non_sparse_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  210    229   
        let handler = self
  211    230   
            .handlers
  212    231   
            .get("null_in_non_sparse")
  213    232   
            .expect("Python handler for operation `null_in_non_sparse` not found")
  214    233   
            .clone();
  215    234   
        let builder = builder.null_in_non_sparse(move |input, state| {
  216    235   
            ::pyo3_asyncio::tokio::scope(
  217    236   
                null_in_non_sparse_locals.clone(),
  218    237   
                crate::python_operation_adaptor::null_in_non_sparse(input, state, handler.clone()),
  219    238   
            )
  220    239   
        });
         240  +
        /* PythonApplicationGenerator.kt:209 */
  221    241   
        let primitive_int_header_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  222    242   
        let handler = self
  223    243   
            .handlers
  224    244   
            .get("primitive_int_header")
  225    245   
            .expect("Python handler for operation `primitive_int_header` not found")
  226    246   
            .clone();
  227    247   
        let builder = builder.primitive_int_header(move |input, state| {
  228    248   
            ::pyo3_asyncio::tokio::scope(
  229    249   
                primitive_int_header_locals.clone(),
  230    250   
                crate::python_operation_adaptor::primitive_int_header(
  231    251   
                    input,
  232    252   
                    state,
  233    253   
                    handler.clone(),
  234    254   
                ),
  235    255   
            )
  236    256   
        });
         257  +
        /* PythonApplicationGenerator.kt:209 */
  237    258   
        let primitive_int_op_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  238    259   
        let handler = self
  239    260   
            .handlers
  240    261   
            .get("primitive_int_op")
  241    262   
            .expect("Python handler for operation `primitive_int_op` not found")
  242    263   
            .clone();
  243    264   
        let builder = builder.primitive_int_op(move |input, state| {
  244    265   
            ::pyo3_asyncio::tokio::scope(
  245    266   
                primitive_int_op_locals.clone(),
  246    267   
                crate::python_operation_adaptor::primitive_int_op(input, state, handler.clone()),
  247    268   
            )
  248    269   
        });
         270  +
        /* PythonApplicationGenerator.kt:209 */
  249    271   
        let query_precedence_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  250    272   
        let handler = self
  251    273   
            .handlers
  252    274   
            .get("query_precedence")
  253    275   
            .expect("Python handler for operation `query_precedence` not found")
  254    276   
            .clone();
  255    277   
        let builder = builder.query_precedence(move |input, state| {
  256    278   
            ::pyo3_asyncio::tokio::scope(
  257    279   
                query_precedence_locals.clone(),
  258    280   
                crate::python_operation_adaptor::query_precedence(input, state, handler.clone()),
  259    281   
            )
  260    282   
        });
         283  +
        /* PythonApplicationGenerator.kt:209 */
  261    284   
        let status_response_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  262    285   
        let handler = self
  263    286   
            .handlers
  264    287   
            .get("status_response")
  265    288   
            .expect("Python handler for operation `status_response` not found")
  266    289   
            .clone();
  267    290   
        let builder = builder.status_response(move |input, state| {
  268    291   
            ::pyo3_asyncio::tokio::scope(
  269    292   
                status_response_locals.clone(),
  270    293   
                crate::python_operation_adaptor::status_response(input, state, handler.clone()),
  271    294   
            )
  272    295   
        });
         296  +
        /* PythonApplicationGenerator.kt:209 */
  273    297   
        let string_payload_locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  274    298   
        let handler = self
  275    299   
            .handlers
  276    300   
            .get("string_payload")
  277    301   
            .expect("Python handler for operation `string_payload` not found")
  278    302   
            .clone();
  279    303   
        let builder = builder.string_payload(move |input, state| {
  280    304   
            ::pyo3_asyncio::tokio::scope(
  281    305   
                string_payload_locals.clone(),
  282    306   
                crate::python_operation_adaptor::string_payload(input, state, handler.clone()),
  283    307   
            )
  284    308   
        });
         309  +
        /* PythonApplicationGenerator.kt:220 */
  285    310   
        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"));
  286    311   
  287    312   
        {
  288    313   
            use ::tower::Layer;
  289    314   
            ::tracing::trace!("adding middlewares to rust python router");
  290    315   
            let mut middlewares = self.middlewares.clone();
  291    316   
            // Reverse the middlewares, so they run with same order as they defined
  292    317   
            middlewares.reverse();
  293    318   
            for handler in middlewares {
  294    319   
                ::tracing::trace!(name = &handler.name, "adding python middleware");
  295    320   
                let locals = ::pyo3_asyncio::TaskLocals::new(event_loop);
  296    321   
                let layer = ::aws_smithy_http_server_python::PyMiddlewareLayer::<
  297    322   
                    ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  298    323   
                >::new(handler, locals);
  299    324   
                service = ::tower::util::BoxCloneService::new(layer.layer(service));
  300    325   
            }
  301    326   
        }
  302    327   
        Ok(service)
         328  +
        /* PythonApplicationGenerator.kt:189 */
  303    329   
    }
         330  +
    /* PythonApplicationGenerator.kt:168 */
  304    331   
}
         332  +
/* PythonApplicationGenerator.kt:247 */
  305    333   
#[::pyo3::pymethods]
  306    334   
impl App {
         335  +
    /* PythonApplicationGenerator.kt:260 */
  307    336   
    /// Create a new [App].
  308    337   
    #[new]
  309    338   
    pub fn new() -> Self {
  310    339   
        Self::default()
  311    340   
    }
  312    341   
  313    342   
    /// Register a context object that will be shared between handlers.
  314    343   
    ///
  315    344   
    /// :param context Ctx:
  316    345   
    /// :rtype None:
@@ -359,388 +543,584 @@
  379    408   
        py: pyo3::Python,
  380    409   
        socket: &pyo3::PyCell<::aws_smithy_http_server_python::PySocket>,
  381    410   
        worker_number: isize,
  382    411   
        tls: Option<::aws_smithy_http_server_python::tls::PyTlsConfig>,
  383    412   
    ) -> pyo3::PyResult<()> {
  384    413   
        use ::aws_smithy_http_server_python::PyApp;
  385    414   
        let event_loop = self.configure_python_event_loop(py)?;
  386    415   
        let service = self.build_and_configure_service(py, event_loop)?;
  387    416   
        self.start_hyper_worker(py, socket, event_loop, service, worker_number, tls)
  388    417   
    }
         418  +
    /* PythonApplicationGenerator.kt:366 */
  389    419   
    /// Method to register `case_insensitive_error_operation` Python implementation inside the handlers map.
  390    420   
    /// It can be used as a function decorator in Python.
  391    421   
    ///
  392    422   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.CaseInsensitiveErrorOperationInput, Ctx\], typing.Union\[rest_json_extras.output.CaseInsensitiveErrorOperationOutput, typing.Awaitable\[rest_json_extras.output.CaseInsensitiveErrorOperationOutput\]\]\], typing.Callable\[\[rest_json_extras.input.CaseInsensitiveErrorOperationInput\], typing.Union\[rest_json_extras.output.CaseInsensitiveErrorOperationOutput, typing.Awaitable\[rest_json_extras.output.CaseInsensitiveErrorOperationOutput\]\]\]\]:
  393    423   
    /// :rtype None:
  394    424   
    #[pyo3(text_signature = "($self, func)")]
  395    425   
    pub fn case_insensitive_error_operation(
  396    426   
        &mut self,
  397    427   
        py: ::pyo3::Python,
  398    428   
        func: ::pyo3::PyObject,
  399    429   
    ) -> ::pyo3::PyResult<()> {
  400    430   
        use ::aws_smithy_http_server_python::PyApp;
  401    431   
        self.register_operation(py, "case_insensitive_error_operation", func)
  402    432   
    }
         433  +
    /* PythonApplicationGenerator.kt:366 */
  403    434   
    /// Method to register `empty_struct_with_content_on_wire_op` Python implementation inside the handlers map.
  404    435   
    /// It can be used as a function decorator in Python.
  405    436   
    ///
  406    437   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.EmptyStructWithContentOnWireOpInput, Ctx\], typing.Union\[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput, typing.Awaitable\[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput\]\]\], typing.Callable\[\[rest_json_extras.input.EmptyStructWithContentOnWireOpInput\], typing.Union\[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput, typing.Awaitable\[rest_json_extras.output.EmptyStructWithContentOnWireOpOutput\]\]\]\]:
  407    438   
    /// :rtype None:
  408    439   
    #[pyo3(text_signature = "($self, func)")]
  409    440   
    pub fn empty_struct_with_content_on_wire_op(
  410    441   
        &mut self,
  411    442   
        py: ::pyo3::Python,
  412    443   
        func: ::pyo3::PyObject,
  413    444   
    ) -> ::pyo3::PyResult<()> {
  414    445   
        use ::aws_smithy_http_server_python::PyApp;
  415    446   
        self.register_operation(py, "empty_struct_with_content_on_wire_op", func)
  416    447   
    }
         448  +
    /* PythonApplicationGenerator.kt:366 */
  417    449   
    /// Method to register `enum_query` Python implementation inside the handlers map.
  418    450   
    /// It can be used as a function decorator in Python.
  419    451   
    ///
  420    452   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.EnumQueryInput, Ctx\], typing.Union\[rest_json_extras.output.EnumQueryOutput, typing.Awaitable\[rest_json_extras.output.EnumQueryOutput\]\]\], typing.Callable\[\[rest_json_extras.input.EnumQueryInput\], typing.Union\[rest_json_extras.output.EnumQueryOutput, typing.Awaitable\[rest_json_extras.output.EnumQueryOutput\]\]\]\]:
  421    453   
    /// :rtype None:
  422    454   
    #[pyo3(text_signature = "($self, func)")]
  423    455   
    pub fn enum_query(
  424    456   
        &mut self,
  425    457   
        py: ::pyo3::Python,
  426    458   
        func: ::pyo3::PyObject,
  427    459   
    ) -> ::pyo3::PyResult<()> {
  428    460   
        use ::aws_smithy_http_server_python::PyApp;
  429    461   
        self.register_operation(py, "enum_query", func)
  430    462   
    }
         463  +
    /* PythonApplicationGenerator.kt:366 */
  431    464   
    /// Method to register `escaped_string_values` Python implementation inside the handlers map.
  432    465   
    /// It can be used as a function decorator in Python.
  433    466   
    ///
  434    467   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.EscapedStringValuesInput, Ctx\], typing.Union\[rest_json_extras.output.EscapedStringValuesOutput, typing.Awaitable\[rest_json_extras.output.EscapedStringValuesOutput\]\]\], typing.Callable\[\[rest_json_extras.input.EscapedStringValuesInput\], typing.Union\[rest_json_extras.output.EscapedStringValuesOutput, typing.Awaitable\[rest_json_extras.output.EscapedStringValuesOutput\]\]\]\]:
  435    468   
    /// :rtype None:
  436    469   
    #[pyo3(text_signature = "($self, func)")]
  437    470   
    pub fn escaped_string_values(
  438    471   
        &mut self,
  439    472   
        py: ::pyo3::Python,
  440    473   
        func: ::pyo3::PyObject,
  441    474   
    ) -> ::pyo3::PyResult<()> {
  442    475   
        use ::aws_smithy_http_server_python::PyApp;
  443    476   
        self.register_operation(py, "escaped_string_values", func)
  444    477   
    }
         478  +
    /* PythonApplicationGenerator.kt:366 */
  445    479   
    /// Method to register `map_with_enum_key_op` Python implementation inside the handlers map.
  446    480   
    /// It can be used as a function decorator in Python.
  447    481   
    ///
  448    482   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.MapWithEnumKeyOpInput, Ctx\], typing.Union\[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable\[rest_json_extras.output.MapWithEnumKeyOpOutput\]\]\], typing.Callable\[\[rest_json_extras.input.MapWithEnumKeyOpInput\], typing.Union\[rest_json_extras.output.MapWithEnumKeyOpOutput, typing.Awaitable\[rest_json_extras.output.MapWithEnumKeyOpOutput\]\]\]\]:
  449    483   
    /// :rtype None:
  450    484   
    #[pyo3(text_signature = "($self, func)")]
  451    485   
    pub fn map_with_enum_key_op(
  452    486   
        &mut self,
  453    487   
        py: ::pyo3::Python,
  454    488   
        func: ::pyo3::PyObject,
  455    489   
    ) -> ::pyo3::PyResult<()> {
  456    490   
        use ::aws_smithy_http_server_python::PyApp;
  457    491   
        self.register_operation(py, "map_with_enum_key_op", func)
  458    492   
    }
         493  +
    /* PythonApplicationGenerator.kt:366 */
  459    494   
    /// Method to register `null_in_non_sparse` Python implementation inside the handlers map.
  460    495   
    /// It can be used as a function decorator in Python.
  461    496   
    ///
  462    497   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.NullInNonSparseInput, Ctx\], typing.Union\[rest_json_extras.output.NullInNonSparseOutput, typing.Awaitable\[rest_json_extras.output.NullInNonSparseOutput\]\]\], typing.Callable\[\[rest_json_extras.input.NullInNonSparseInput\], typing.Union\[rest_json_extras.output.NullInNonSparseOutput, typing.Awaitable\[rest_json_extras.output.NullInNonSparseOutput\]\]\]\]:
  463    498   
    /// :rtype None:
  464    499   
    #[pyo3(text_signature = "($self, func)")]
  465    500   
    pub fn null_in_non_sparse(
  466    501   
        &mut self,
  467    502   
        py: ::pyo3::Python,
  468    503   
        func: ::pyo3::PyObject,
  469    504   
    ) -> ::pyo3::PyResult<()> {
  470    505   
        use ::aws_smithy_http_server_python::PyApp;
  471    506   
        self.register_operation(py, "null_in_non_sparse", func)
  472    507   
    }
         508  +
    /* PythonApplicationGenerator.kt:366 */
  473    509   
    /// Method to register `primitive_int_header` Python implementation inside the handlers map.
  474    510   
    /// It can be used as a function decorator in Python.
  475    511   
    ///
  476    512   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.PrimitiveIntHeaderInput, Ctx\], typing.Union\[rest_json_extras.output.PrimitiveIntHeaderOutput, typing.Awaitable\[rest_json_extras.output.PrimitiveIntHeaderOutput\]\]\], typing.Callable\[\[rest_json_extras.input.PrimitiveIntHeaderInput\], typing.Union\[rest_json_extras.output.PrimitiveIntHeaderOutput, typing.Awaitable\[rest_json_extras.output.PrimitiveIntHeaderOutput\]\]\]\]:
  477    513   
    /// :rtype None:
  478    514   
    #[pyo3(text_signature = "($self, func)")]
  479    515   
    pub fn primitive_int_header(
  480    516   
        &mut self,
  481    517   
        py: ::pyo3::Python,
  482    518   
        func: ::pyo3::PyObject,
  483    519   
    ) -> ::pyo3::PyResult<()> {
  484    520   
        use ::aws_smithy_http_server_python::PyApp;
  485    521   
        self.register_operation(py, "primitive_int_header", func)
  486    522   
    }
         523  +
    /* PythonApplicationGenerator.kt:366 */
  487    524   
    /// Method to register `primitive_int_op` Python implementation inside the handlers map.
  488    525   
    /// It can be used as a function decorator in Python.
  489    526   
    ///
  490    527   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.PrimitiveIntOpInput, Ctx\], typing.Union\[rest_json_extras.output.PrimitiveIntOpOutput, typing.Awaitable\[rest_json_extras.output.PrimitiveIntOpOutput\]\]\], typing.Callable\[\[rest_json_extras.input.PrimitiveIntOpInput\], typing.Union\[rest_json_extras.output.PrimitiveIntOpOutput, typing.Awaitable\[rest_json_extras.output.PrimitiveIntOpOutput\]\]\]\]:
  491    528   
    /// :rtype None:
  492    529   
    #[pyo3(text_signature = "($self, func)")]
  493    530   
    pub fn primitive_int_op(
  494    531   
        &mut self,
  495    532   
        py: ::pyo3::Python,
  496    533   
        func: ::pyo3::PyObject,
  497    534   
    ) -> ::pyo3::PyResult<()> {
  498    535   
        use ::aws_smithy_http_server_python::PyApp;
  499    536   
        self.register_operation(py, "primitive_int_op", func)
  500    537   
    }
         538  +
    /* PythonApplicationGenerator.kt:366 */
  501    539   
    /// Method to register `query_precedence` Python implementation inside the handlers map.
  502    540   
    /// It can be used as a function decorator in Python.
  503    541   
    ///
  504    542   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.QueryPrecedenceInput, Ctx\], typing.Union\[rest_json_extras.output.QueryPrecedenceOutput, typing.Awaitable\[rest_json_extras.output.QueryPrecedenceOutput\]\]\], typing.Callable\[\[rest_json_extras.input.QueryPrecedenceInput\], typing.Union\[rest_json_extras.output.QueryPrecedenceOutput, typing.Awaitable\[rest_json_extras.output.QueryPrecedenceOutput\]\]\]\]:
  505    543   
    /// :rtype None:
  506    544   
    #[pyo3(text_signature = "($self, func)")]
  507    545   
    pub fn query_precedence(
  508    546   
        &mut self,
  509    547   
        py: ::pyo3::Python,
  510    548   
        func: ::pyo3::PyObject,
  511    549   
    ) -> ::pyo3::PyResult<()> {
  512    550   
        use ::aws_smithy_http_server_python::PyApp;
  513    551   
        self.register_operation(py, "query_precedence", func)
  514    552   
    }
         553  +
    /* PythonApplicationGenerator.kt:366 */
  515    554   
    /// Method to register `status_response` Python implementation inside the handlers map.
  516    555   
    /// It can be used as a function decorator in Python.
  517    556   
    ///
  518    557   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.StatusResponseInput, Ctx\], typing.Union\[rest_json_extras.output.StatusResponseOutput, typing.Awaitable\[rest_json_extras.output.StatusResponseOutput\]\]\], typing.Callable\[\[rest_json_extras.input.StatusResponseInput\], typing.Union\[rest_json_extras.output.StatusResponseOutput, typing.Awaitable\[rest_json_extras.output.StatusResponseOutput\]\]\]\]:
  519    558   
    /// :rtype None:
  520    559   
    #[pyo3(text_signature = "($self, func)")]
  521    560   
    pub fn status_response(
  522    561   
        &mut self,
  523    562   
        py: ::pyo3::Python,
  524    563   
        func: ::pyo3::PyObject,
  525    564   
    ) -> ::pyo3::PyResult<()> {
  526    565   
        use ::aws_smithy_http_server_python::PyApp;
  527    566   
        self.register_operation(py, "status_response", func)
  528    567   
    }
         568  +
    /* PythonApplicationGenerator.kt:366 */
  529    569   
    /// Method to register `string_payload` Python implementation inside the handlers map.
  530    570   
    /// It can be used as a function decorator in Python.
  531    571   
    ///
  532    572   
    /// :param func typing.Union\[typing.Callable\[\[rest_json_extras.input.StringPayloadInput, Ctx\], typing.Union\[rest_json_extras.output.StringPayloadOutput, typing.Awaitable\[rest_json_extras.output.StringPayloadOutput\]\]\], typing.Callable\[\[rest_json_extras.input.StringPayloadInput\], typing.Union\[rest_json_extras.output.StringPayloadOutput, typing.Awaitable\[rest_json_extras.output.StringPayloadOutput\]\]\]\]:
  533    573   
    /// :rtype None:
  534    574   
    #[pyo3(text_signature = "($self, func)")]
  535    575   
    pub fn string_payload(
  536    576   
        &mut self,
  537    577   
        py: ::pyo3::Python,
  538    578   
        func: ::pyo3::PyObject,
  539    579   
    ) -> ::pyo3::PyResult<()> {
  540    580   
        use ::aws_smithy_http_server_python::PyApp;
  541    581   
        self.register_operation(py, "string_payload", func)
  542    582   
    }
         583  +
    /* PythonApplicationGenerator.kt:247 */
  543    584   
}

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/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 [`RestJsonExtras`].
    3      4   
///
    4      5   
/// Constructed via [`RestJsonExtras::builder`].
    5      6   
pub struct RestJsonExtrasBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    case_insensitive_error_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    empty_struct_with_content_on_wire_op: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    enum_query: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    escaped_string_values: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    map_with_enum_key_op: Option<::aws_smithy_http_server::routing::Route<Body>>,
   11     12   
    null_in_non_sparse: Option<::aws_smithy_http_server::routing::Route<Body>>,
@@ -2477,2478 +2536,2538 @@
 2497   2498   
            "aws.protocoltests.restjson",
 2498   2499   
            "RestJsonExtras",
 2499   2500   
        );
 2500   2501   
 2501   2502   
    const VERSION: Option<&'static str> = Some("2019-12-16");
 2502   2503   
 2503   2504   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
 2504   2505   
 2505   2506   
    type Operations = Operation;
 2506   2507   
}
        2508  +
/* ServiceConfigGenerator.kt:178 */
 2507   2509   
/// Configuration for the [`RestJsonExtras`]. This is the central place where to register and
 2508   2510   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 2509   2511   
///
 2510   2512   
/// ```rust,no_run
 2511   2513   
/// # use rest_json_extras::RestJsonExtrasConfig;
 2512   2514   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 2513   2515   
/// # use ::tower::layer::util::Identity;
 2514   2516   
/// # let authentication_plugin = IdentityPlugin;
 2515   2517   
/// # let authorization_plugin = IdentityPlugin;
 2516   2518   
/// # let server_request_id_provider_layer = Identity::new();
@@ -2598,2600 +2657,2660 @@
 2618   2620   
 2619   2621   
    /// Build the configuration.
 2620   2622   
    pub fn build(self) -> super::RestJsonExtrasConfig<L, H, M> {
 2621   2623   
        super::RestJsonExtrasConfig {
 2622   2624   
            layers: self.layers,
 2623   2625   
            http_plugins: self.http_plugins,
 2624   2626   
            model_plugins: self.model_plugins,
 2625   2627   
        }
 2626   2628   
    }
 2627   2629   
}
        2630  +
/* ScopeMacroGenerator.kt:81 */
 2628   2631   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 2629   2632   
///
 2630   2633   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 2631   2634   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 2632   2635   
///
 2633   2636   
/// # Example
 2634   2637   
///
 2635   2638   
/// ```rust
 2636   2639   
/// scope! {
 2637   2640   
///     /// Includes [`CaseInsensitiveErrorOperation`], excluding all other operations.

tmp-codegen-diff/codegen-server-test-python/rest_json_extras/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/rest_json_extras/rust-server-codegen-python/src/unconstrained.rs

@@ -1,1 +40,50 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
    3      3   
pub(crate) mod map_with_enum_key_unconstrained {
    4      4   
           5  +
    /* UnconstrainedMapGenerator.kt:79 */
    5      6   
    #[derive(Debug, Clone)]
    6      7   
    pub(crate) struct MapWithEnumKeyUnconstrained(
    7      8   
        pub(crate) std::collections::HashMap<::std::string::String, ::std::string::String>,
    8      9   
    );
    9     10   
   10     11   
    impl From<MapWithEnumKeyUnconstrained>
   11     12   
        for crate::constrained::MaybeConstrained<
   12     13   
            crate::constrained::map_with_enum_key_constrained::MapWithEnumKeyConstrained,
   13     14   
        >
   14     15   
    {
   15     16   
        fn from(value: MapWithEnumKeyUnconstrained) -> Self {
   16     17   
            Self::Unconstrained(value)
   17     18   
        }
   18     19   
    }
          20  +
    /* UnconstrainedMapGenerator.kt:101 */
   19     21   
    impl std::convert::TryFrom<MapWithEnumKeyUnconstrained>
   20     22   
        for crate::constrained::map_with_enum_key_constrained::MapWithEnumKeyConstrained
   21     23   
    {
          24  +
        /* UnconstrainedMapGenerator.kt:102 */
   22     25   
        type Error = crate::model::map_with_enum_key_internal::ConstraintViolation;
          26  +
        /* UnconstrainedMapGenerator.kt:104 */
   23     27   
        fn try_from(value: MapWithEnumKeyUnconstrained) -> std::result::Result<Self, Self::Error> {
          28  +
            /* UnconstrainedMapGenerator.kt:186 */
   24     29   
            let res: ::std::result::Result<
   25     30   
                ::std::collections::HashMap<crate::model::StringEnum, ::std::string::String>,
   26     31   
                Self::Error,
   27     32   
            > = value
   28     33   
                .0
   29     34   
                .into_iter()
   30     35   
                .map(|(k, v)| {
   31     36   
                    let k: crate::model::StringEnum = k.try_into().map_err(Self::Error::Key)?;
   32     37   
   33     38   
                    Ok((k, v))
   34     39   
                })
   35     40   
                .collect();
   36     41   
            let hm = res?;
          42  +
            /* UnconstrainedMapGenerator.kt:247 */
   37     43   
            Ok(Self(hm))
          44  +
            /* UnconstrainedMapGenerator.kt:104 */
   38     45   
        }
          46  +
        /* UnconstrainedMapGenerator.kt:101 */
   39     47   
    }
          48  +
          49  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   40     50   
}

tmp-codegen-diff/codegen-server-test-python/simple/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/simple/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 `Operation` operation.
           4  +
/* ServerOperationErrorGenerator.kt:64 */
    3      5   
/// Each variant represents an error that can occur for the `Operation` operation.
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(::std::fmt::Debug)]
    5         -
pub enum OperationError {
           8  +
pub /* ServerOperationErrorGenerator.kt:66 */ enum OperationError {
           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 OperationError {
          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         -
            OperationError::InternalServerError(_inner) => _inner.fmt(f),
          21  +
            /* ServerOperationErrorGenerator.kt:142 */
          22  +
            OperationError::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 OperationError {
          35  +
    /* ServerOperationErrorGenerator.kt:87 */
   17     36   
    /// Returns `true` if the error kind is `OperationError::InternalServerError`.
          37  +
    /* ServerOperationErrorGenerator.kt:88 */
   18     38   
    pub fn is_internal_server_error(&self) -> bool {
          39  +
        /* ServerOperationErrorGenerator.kt:89 */
   19     40   
        matches!(&self, OperationError::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         -
            OperationError::InternalServerError(_inner) => _inner.name(),
          49  +
            /* ServerOperationErrorGenerator.kt:142 */
          50  +
            OperationError::InternalServerError(_inner) =>
          51  +
            /* ServerOperationErrorGenerator.kt:95 */
          52  +
            {
          53  +
                _inner.name()
          54  +
            }
          55  +
            /* ServerOperationErrorGenerator.kt:139 */
   25     56   
        }
          57  +
        /* ServerOperationErrorGenerator.kt:93 */
   26     58   
    }
          59  +
    /* ServerOperationErrorGenerator.kt:83 */
   27     60   
}
          61  +
/* ServerOperationErrorGenerator.kt:100 */
   28     62   
impl ::std::error::Error for OperationError {
          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         -
            OperationError::InternalServerError(_inner) => Some(_inner),
          67  +
            /* ServerOperationErrorGenerator.kt:142 */
          68  +
            OperationError::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::OperationError {
          81  +
    /* ServerOperationErrorGenerator.kt:111 */
   36     82   
    fn from(variant: crate::error::InternalServerError) -> crate::error::OperationError {
          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::OperationError {
   42     92   
    fn from(variant: ::pyo3::PyErr) -> crate::error::OperationError {
   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/simple/rust-server-codegen-python/src/input.rs

@@ -1,1 +118,183 @@
    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 message typing.Optional\[str\]:
    4      6   
/// :rtype None:
           7  +
/* StructureGenerator.kt:197 */
    5      8   
#[allow(missing_docs)] // documentation missing in model
           9  +
/* RustType.kt:516 */
    6     10   
#[derive(
    7     11   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    8     12   
)]
    9         -
pub struct OperationInput {
          13  +
pub /* StructureGenerator.kt:201 */ struct OperationInput {
          14  +
    /* RustType.kt:516 */
   10     15   
    #[pyo3(get, set)]
          16  +
    /* PythonServerStructureGenerator.kt:80 */
   11     17   
    /// :type typing.Optional\[str\]:
          18  +
    /* StructureGenerator.kt:231 */
   12     19   
    #[allow(missing_docs)] // documentation missing in model
   13     20   
    pub message: ::std::option::Option<::std::string::String>,
          21  +
    /* StructureGenerator.kt:201 */
   14     22   
}
          23  +
/* StructureGenerator.kt:135 */
   15     24   
impl OperationInput {
          25  +
    /* StructureGenerator.kt:231 */
   16     26   
    #[allow(missing_docs)] // documentation missing in model
          27  +
                           /* StructureGenerator.kt:166 */
   17     28   
    pub fn message(&self) -> ::std::option::Option<&str> {
          29  +
        /* StructureGenerator.kt:169 */
   18     30   
        self.message.as_deref()
          31  +
        /* StructureGenerator.kt:166 */
   19     32   
    }
          33  +
    /* StructureGenerator.kt:135 */
   20     34   
}
          35  +
/* RustType.kt:516 */
   21     36   
#[allow(clippy::new_without_default)]
          37  +
/* RustType.kt:516 */
   22     38   
#[allow(clippy::too_many_arguments)]
          39  +
/* RustType.kt:516 */
   23     40   
#[::pyo3::pymethods]
          41  +
/* PythonServerStructureGenerator.kt:88 */
   24     42   
impl OperationInput {
   25     43   
    #[new]
   26     44   
    pub fn new(message: ::std::option::Option<::std::string::String>) -> Self {
   27     45   
        Self { message }
   28     46   
    }
   29     47   
    fn __repr__(&self) -> String {
   30     48   
        format!("{self:?}")
   31     49   
    }
   32     50   
    fn __str__(&self) -> String {
   33     51   
        format!("{self:?}")
   34     52   
    }
   35     53   
}
          54  +
/* PythonServerStructureGenerator.kt:111 */
   36     55   
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<OperationInput> {
   37     56   
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
   38     57   
        ob.extract::<OperationInput>().map(Box::new)
   39     58   
    }
   40     59   
}
   41     60   
   42     61   
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<OperationInput> {
   43     62   
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
   44     63   
        (*self).into_py(py)
   45     64   
    }
   46     65   
}
          66  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
   47     67   
impl crate::constrained::Constrained for crate::input::OperationInput {
   48     68   
    type Unconstrained = crate::input::operation_input_internal::Builder;
   49     69   
}
          70  +
/* ServerCodegenVisitor.kt:370 */
   50     71   
impl OperationInput {
   51         -
    /// Creates a new builder-style object to manufacture [`OperationInput`](crate::input::OperationInput).
          72  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`OperationInput`](crate::input::OperationInput).
          73  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   52     74   
    pub fn builder() -> crate::input::operation_input::Builder {
          75  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   53     76   
        crate::input::operation_input::Builder::default()
          77  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   54     78   
    }
          79  +
    /* ServerCodegenVisitor.kt:370 */
   55     80   
}
   56         -
/// See [`OperationInput`](crate::input::OperationInput).
          81  +
/// /* ServerBuilderGenerator.kt:171 */See [`OperationInput`](crate::input::OperationInput).
   57     82   
pub(crate) mod operation_input_internal {
   58     83   
          84  +
    /* ServerBuilderGenerator.kt:461 */
   59     85   
    impl ::std::convert::From<Builder> for crate::input::OperationInput {
   60     86   
        fn from(builder: Builder) -> Self {
   61     87   
            builder.build()
   62     88   
        }
   63     89   
    }
   64         -
    /// A builder for [`OperationInput`](crate::input::OperationInput).
          90  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`OperationInput`](crate::input::OperationInput).
          91  +
    /* RustType.kt:516 */
   65     92   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          93  +
    /* ServerBuilderGenerator.kt:211 */
   66     94   
    pub(crate) struct Builder {
          95  +
        /* ServerBuilderGenerator.kt:308 */
   67     96   
        pub(crate) message: ::std::option::Option<::std::string::String>,
          97  +
        /* ServerBuilderGenerator.kt:211 */
   68     98   
    }
          99  +
    /* ServerBuilderGenerator.kt:215 */
   69    100   
    impl Builder {
         101  +
        /* ServerBuilderGenerator.kt:426 */
   70    102   
        #[allow(missing_docs)] // documentation missing in model
         103  +
                               /* ServerBuilderGenerator.kt:428 */
   71    104   
        pub(crate) fn set_message(
   72    105   
            mut self,
   73    106   
            input: Option<impl ::std::convert::Into<::std::string::String>>,
   74    107   
        ) -> Self {
         108  +
            /* ServerBuilderGenerator.kt:429 */
   75    109   
            self.message = input.map(|v| v.into());
   76    110   
            self
         111  +
            /* ServerBuilderGenerator.kt:428 */
   77    112   
        }
   78         -
        /// Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         113  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         114  +
        /* ServerBuilderGenerator.kt:271 */
   79    115   
        pub fn build(self) -> crate::input::OperationInput {
   80    116   
            self.build_enforcing_all_constraints()
   81    117   
        }
         118  +
        /* ServerBuilderGenerator.kt:283 */
   82    119   
        fn build_enforcing_all_constraints(self) -> crate::input::OperationInput {
         120  +
            /* ServerBuilderGenerator.kt:542 */
   83    121   
            crate::input::OperationInput {
         122  +
                /* ServerBuilderGenerator.kt:546 */
   84    123   
                message: self.message,
         124  +
                /* ServerBuilderGenerator.kt:542 */
   85    125   
            }
         126  +
            /* ServerBuilderGenerator.kt:283 */
   86    127   
        }
         128  +
        /* ServerBuilderGenerator.kt:215 */
   87    129   
    }
         130  +
         131  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   88    132   
}
   89         -
/// See [`OperationInput`](crate::input::OperationInput).
         133  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`OperationInput`](crate::input::OperationInput).
   90    134   
pub mod operation_input {
   91    135   
         136  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
   92    137   
    impl ::std::convert::From<Builder> for crate::input::OperationInput {
   93    138   
        fn from(builder: Builder) -> Self {
   94    139   
            builder.build()
   95    140   
        }
   96    141   
    }
   97         -
    /// A builder for [`OperationInput`](crate::input::OperationInput).
         142  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`OperationInput`](crate::input::OperationInput).
         143  +
    /* RustType.kt:516 */
   98    144   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         145  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   99    146   
    pub struct Builder {
         147  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  100    148   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         149  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  101    150   
    }
         151  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  102    152   
    impl Builder {
         153  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  103    154   
        #[allow(missing_docs)] // documentation missing in model
         155  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  104    156   
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
  105         -
            self.message = input;
         157  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         158  +
            self.message =
         159  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         160  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  106    161   
            self
         162  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  107    163   
        }
  108         -
        /// Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         164  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         165  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
  109    166   
        pub fn build(self) -> crate::input::OperationInput {
  110    167   
            self.build_enforcing_required_and_enum_traits()
  111    168   
        }
         169  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  112    170   
        fn build_enforcing_required_and_enum_traits(self) -> crate::input::OperationInput {
         171  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
  113    172   
            crate::input::OperationInput {
         173  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
  114    174   
                message: self.message,
         175  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
  115    176   
            }
         177  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  116    178   
        }
         179  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  117    180   
    }
         181  +
         182  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  118    183   
}

tmp-codegen-diff/codegen-server-test-python/simple/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   
//! simple
   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 SimpleService Smithy service.
   24     25   
//!
   25     26   
//! # Using SimpleService
   26     27   
//!
   27     28   
//! The primary entrypoint is [`SimpleService`]: 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 [`SimpleService::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 +256,269 @@
  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, SimpleService, SimpleServiceBuilder, SimpleServiceConfig,
  199    201   
    SimpleServiceConfigBuilder,
  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         -
/// All operations that this crate can perform.
         222  +
/// /* ServerRustModule.kt:55 */All operations that this crate can perform.
  218    223   
pub mod operation;
  219    224   
         225  +
/* ServerRustModule.kt:79 */
  220    226   
/// A collection of types representing each operation defined in the service closure.
  221    227   
///
  222    228   
/// The [plugin system](::aws_smithy_http_server::plugin) makes use of these
  223    229   
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
  224    230   
/// parameterize [`Plugin`](::aws_smithy_http_server::plugin::Plugin) implementations. Their traits, such as
  225    231   
/// [`OperationShape`](::aws_smithy_http_server::operation::OperationShape), can be used to provide
  226    232   
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
  227    233   
pub mod operation_shape;
  228    234   
  229         -
/// Output structures for operations. Documentation on these types is copied from the model.
         235  +
/// /* ServerRustModule.kt:55 */Output structures for operations. Documentation on these types is copied from the model.
  230    236   
pub mod output;
  231    237   
  232         -
/// Export PyO3 symbols in the shared library
         238  +
/// /* PythonServerRustModule.kt:23 */Export PyO3 symbols in the shared library
  233    239   
pub mod python_module_export;
  234    240   
  235         -
/// Operation adapters that delegate to Python handlers.
         241  +
/// /* PythonServerRustModule.kt:23 */Operation adapters that delegate to Python handlers.
  236    242   
pub mod python_operation_adaptor;
  237    243   
  238         -
/// Python server and application implementation.
         244  +
/// /* PythonServerRustModule.kt:23 */Python server and application implementation.
  239    245   
pub mod python_server_application;
  240    246   
         247  +
/* RustModule.kt:172 */
  241    248   
mod service;
  242    249   
  243         -
/// Data primitives referenced by other data types.
         250  +
/// /* ServerRustModule.kt:55 */Data primitives referenced by other data types.
  244    251   
pub mod types;
  245    252   
  246         -
/// Constrained types for constrained shapes.
         253  +
/// /* ServerRustModule.kt:55 */Constrained types for constrained shapes.
         254  +
/* RustModule.kt:172 */
  247    255   
mod constrained;
  248    256   
  249    257   
pub(crate) mod protocol_serde;
  250    258   
  251         -
/// Re-exported Python types from supporting crates.
         259  +
/// /* PythonServerCodegenDecorator.kt:57 */Re-exported Python types from supporting crates.
         260  +
/* PythonServerCodegenDecorator.kt:58 */
  252    261   
pub mod python_types {
         262  +
    /* PythonServerCodegenDecorator.kt:59 */
  253    263   
    pub use ::aws_smithy_http_server_python::types::Blob;
         264  +
    /* PythonServerCodegenDecorator.kt:60 */
  254    265   
    pub use ::aws_smithy_http_server_python::types::DateTime;
         266  +
    /* PythonServerCodegenDecorator.kt:61 */
  255    267   
    pub use ::aws_smithy_http_server_python::types::Document;
         268  +
    /* PythonServerCodegenDecorator.kt:58 */
  256    269   
}

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/operation.rs

@@ -1,1 +31,32 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerHttpBoundProtocolGenerator.kt:266 */
    2      3   
const CONTENT_TYPE_OPERATION: ::mime::Mime = ::mime::APPLICATION_JSON;
    3      4   
::pin_project_lite::pin_project! {
    4      5   
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
    5      6   
    /// [`OperationInput`](crate::input::OperationInput) using modelled bindings.
    6      7   
    pub struct OperationInputFuture {
    7      8   
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::OperationInput, ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
    8      9   
    }
    9     10   
}
   10     11   
   11     12   
impl std::future::Future for OperationInputFuture {
@@ -38,39 +102,105 @@
   58     59   
                ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(
   59     60   
                    e,
   60     61   
                )
   61     62   
            },
   62     63   
        );
   63     64   
        OperationInputFuture {
   64     65   
            inner: Box::pin(fut),
   65     66   
        }
   66     67   
    }
   67     68   
}
          69  +
/* ServerHttpBoundProtocolGenerator.kt:329 */
   68     70   
impl
   69     71   
    ::aws_smithy_http_server::response::IntoResponse<
   70     72   
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
   71     73   
    > for crate::output::OperationOutput
   72     74   
{
   73     75   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   74     76   
        match crate::protocol_serde::shape_operation::ser_operation_http_response(self) {
   75     77   
            Ok(response) => response,
   76     78   
            Err(e) => {
   77     79   
                ::tracing::error!(error = %e, "failed to serialize response");
   78     80   
                ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
   79     81   
            }
   80     82   
        }
   81     83   
    }
   82     84   
}
          85  +
/* ServerHttpBoundProtocolGenerator.kt:350 */
   83     86   
impl
   84     87   
    ::aws_smithy_http_server::response::IntoResponse<
   85     88   
        ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
   86     89   
    > for crate::error::OperationError
   87     90   
{
   88     91   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   89     92   
        match crate::protocol_serde::shape_operation::ser_operation_http_error(&self) {
   90     93   
            Ok(mut response) => {
   91     94   
                response.extensions_mut().insert(
   92     95   
                    ::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()),

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/operation_shape.rs

@@ -1,1 +0,41 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* ServerOperationGenerator.kt:48 */
    2      3   
#[allow(missing_docs)] // documentation missing in model
           4  +
                       /* ServerOperationGenerator.kt:55 */
    3      5   
pub struct Operation;
    4      6   
    5      7   
impl ::aws_smithy_http_server::operation::OperationShape for Operation {
    6      8   
    const ID: ::aws_smithy_http_server::shape_id::ShapeId =
    7      9   
        ::aws_smithy_http_server::shape_id::ShapeId::new(
    8     10   
            "com.amazonaws.simple#Operation",
    9     11   
            "com.amazonaws.simple",
   10     12   
            "Operation",
   11     13   
        );
   12     14   
   13     15   
    type Input = crate::input::OperationInput;
   14     16   
    type Output = crate::output::OperationOutput;
   15     17   
    type Error = crate::error::OperationError;
   16     18   
}
   17     19   
   18     20   
impl ::aws_smithy_http_server::instrumentation::sensitivity::Sensitivity for Operation {
   19     21   
    type RequestFmt = ::aws_smithy_http_server::instrumentation::sensitivity::RequestFmt<
   20     22   
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   21     23   
        ::aws_smithy_http_server::instrumentation::sensitivity::uri::MakeUri<
   22     24   
            ::aws_smithy_http_server::instrumentation::MakeIdentity,
   23     25   
            ::aws_smithy_http_server::instrumentation::MakeIdentity,
   24     26   
        >,
   25     27   
    >;
   26     28   
    type ResponseFmt = ::aws_smithy_http_server::instrumentation::sensitivity::ResponseFmt<
   27     29   
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   28     30   
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   29     31   
    >;
   30     32   
   31     33   
    fn request_fmt() -> Self::RequestFmt {
   32     34   
        ::aws_smithy_http_server::instrumentation::sensitivity::RequestFmt::new()
   33     35   
    }
   34     36   
   35     37   
    fn response_fmt() -> Self::ResponseFmt {
   36     38   
        ::aws_smithy_http_server::instrumentation::sensitivity::ResponseFmt::new()
   37     39   
    }
   38     40   
}
          41  +
/* ServerOperationGenerator.kt:88 */

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/output.rs

@@ -1,1 +82,127 @@
    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 message typing.Optional\[str\]:
    4      6   
/// :rtype None:
           7  +
/* StructureGenerator.kt:197 */
    5      8   
#[allow(missing_docs)] // documentation missing in model
           9  +
/* RustType.kt:516 */
    6     10   
#[derive(
    7     11   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    8     12   
)]
    9         -
pub struct OperationOutput {
          13  +
pub /* StructureGenerator.kt:201 */ struct OperationOutput {
          14  +
    /* RustType.kt:516 */
   10     15   
    #[pyo3(get, set)]
          16  +
    /* PythonServerStructureGenerator.kt:80 */
   11     17   
    /// :type typing.Optional\[str\]:
          18  +
    /* StructureGenerator.kt:231 */
   12     19   
    #[allow(missing_docs)] // documentation missing in model
   13     20   
    pub message: ::std::option::Option<::std::string::String>,
          21  +
    /* StructureGenerator.kt:201 */
   14     22   
}
          23  +
/* StructureGenerator.kt:135 */
   15     24   
impl OperationOutput {
          25  +
    /* StructureGenerator.kt:231 */
   16     26   
    #[allow(missing_docs)] // documentation missing in model
          27  +
                           /* StructureGenerator.kt:166 */
   17     28   
    pub fn message(&self) -> ::std::option::Option<&str> {
          29  +
        /* StructureGenerator.kt:169 */
   18     30   
        self.message.as_deref()
          31  +
        /* StructureGenerator.kt:166 */
   19     32   
    }
          33  +
    /* StructureGenerator.kt:135 */
   20     34   
}
          35  +
/* RustType.kt:516 */
   21     36   
#[allow(clippy::new_without_default)]
          37  +
/* RustType.kt:516 */
   22     38   
#[allow(clippy::too_many_arguments)]
          39  +
/* RustType.kt:516 */
   23     40   
#[::pyo3::pymethods]
          41  +
/* PythonServerStructureGenerator.kt:88 */
   24     42   
impl OperationOutput {
   25     43   
    #[new]
   26     44   
    pub fn new(message: ::std::option::Option<::std::string::String>) -> Self {
   27     45   
        Self { message }
   28     46   
    }
   29     47   
    fn __repr__(&self) -> String {
   30     48   
        format!("{self:?}")
   31     49   
    }
   32     50   
    fn __str__(&self) -> String {
   33     51   
        format!("{self:?}")
   34     52   
    }
   35     53   
}
          54  +
/* PythonServerStructureGenerator.kt:111 */
   36     55   
impl<'source> ::pyo3::FromPyObject<'source> for std::boxed::Box<OperationOutput> {
   37     56   
    fn extract(ob: &'source ::pyo3::PyAny) -> ::pyo3::PyResult<Self> {
   38     57   
        ob.extract::<OperationOutput>().map(Box::new)
   39     58   
    }
   40     59   
}
   41     60   
   42     61   
impl ::pyo3::IntoPy<::pyo3::PyObject> for std::boxed::Box<OperationOutput> {
   43     62   
    fn into_py(self, py: ::pyo3::Python<'_>) -> ::pyo3::PyObject {
   44     63   
        (*self).into_py(py)
   45     64   
    }
   46     65   
}
          66  +
/* ServerCodegenVisitor.kt:370 */
   47     67   
impl OperationOutput {
   48         -
    /// Creates a new builder-style object to manufacture [`OperationOutput`](crate::output::OperationOutput).
          68  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`OperationOutput`](crate::output::OperationOutput).
          69  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   49     70   
    pub fn builder() -> crate::output::operation_output::Builder {
          71  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   50     72   
        crate::output::operation_output::Builder::default()
          73  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   51     74   
    }
          75  +
    /* ServerCodegenVisitor.kt:370 */
   52     76   
}
   53         -
/// See [`OperationOutput`](crate::output::OperationOutput).
          77  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`OperationOutput`](crate::output::OperationOutput).
   54     78   
pub mod operation_output {
   55     79   
          80  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
   56     81   
    impl ::std::convert::From<Builder> for crate::output::OperationOutput {
   57     82   
        fn from(builder: Builder) -> Self {
   58     83   
            builder.build()
   59     84   
        }
   60     85   
    }
   61         -
    /// A builder for [`OperationOutput`](crate::output::OperationOutput).
          86  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`OperationOutput`](crate::output::OperationOutput).
          87  +
    /* RustType.kt:516 */
   62     88   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          89  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   63     90   
    pub struct Builder {
          91  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
   64     92   
        pub(crate) message: ::std::option::Option<::std::string::String>,
          93  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   65     94   
    }
          95  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   66     96   
    impl Builder {
          97  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
   67     98   
        #[allow(missing_docs)] // documentation missing in model
          99  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   68    100   
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
   69         -
            self.message = input;
         101  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         102  +
            self.message =
         103  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         104  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
   70    105   
            self
         106  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   71    107   
        }
   72         -
        /// Consumes the builder and constructs a [`OperationOutput`](crate::output::OperationOutput).
         108  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`OperationOutput`](crate::output::OperationOutput).
         109  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
   73    110   
        pub fn build(self) -> crate::output::OperationOutput {
   74    111   
            self.build_enforcing_required_and_enum_traits()
   75    112   
        }
         113  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   76    114   
        fn build_enforcing_required_and_enum_traits(self) -> crate::output::OperationOutput {
         115  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   77    116   
            crate::output::OperationOutput {
         117  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
   78    118   
                message: self.message,
         119  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   79    120   
            }
         121  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   80    122   
        }
         123  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   81    124   
    }
         125  +
         126  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   82    127   
}

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

@@ -1,1 +14,15 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
pub(crate) mod shape_operation;
    3      3   
    4      4   
pub(crate) mod shape_internal_server_error;
    5      5   
           6  +
/* JsonParserGenerator.kt:227 */
    6      7   
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
    7      8   
    if data.is_empty() {
    8      9   
        b"{}"
    9     10   
    } else {
   10     11   
        data
   11     12   
    }
   12     13   
}
   13     14   
   14     15   
pub(crate) mod shape_operation_output;

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/protocol_serde/shape_internal_server_error.rs

@@ -1,1 +23,34 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* JsonSerializerGenerator.kt:213 */
    2      3   
pub fn ser_internal_server_error_error(
    3      4   
    value: &crate::error::InternalServerError,
    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_internal_server_error::ser_internal_server_error(
    8     11   
        &mut object,
    9     12   
        value,
   10     13   
    )?;
          14  +
    /* JsonSerializerGenerator.kt:227 */
   11     15   
    object.finish();
   12     16   
    Ok(out)
          17  +
    /* JsonSerializerGenerator.kt:213 */
   13     18   
}
   14     19   
          20  +
/* JsonSerializerGenerator.kt:358 */
   15     21   
pub fn ser_internal_server_error(
   16     22   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   17     23   
    input: &crate::error::InternalServerError,
   18     24   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          25  +
    /* SerializerUtil.kt:42 */
   19     26   
    {
          27  +
        /* JsonSerializerGenerator.kt:423 */
   20     28   
        object.key("message").string(input.message.as_str());
          29  +
        /* SerializerUtil.kt:42 */
   21     30   
    }
          31  +
    /* JsonSerializerGenerator.kt:372 */
   22     32   
    Ok(())
          33  +
    /* JsonSerializerGenerator.kt:358 */
   23     34   
}

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/protocol_serde/shape_operation.rs

@@ -1,1 +150,213 @@
    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_operation_http_request<B>(
    4      6   
    #[allow(unused_variables)] request: ::http::Request<B>,
    5      7   
) -> std::result::Result<
    6      8   
    crate::input::OperationInput,
    7      9   
    ::aws_smithy_http_server::protocol::rest_json_1::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::rest_json_1::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::operation_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/json"),
   27     37   
            )?;
   28     38   
            input = crate::protocol_serde::shape_operation::de_operation(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_operation_http_response(
   36     52   
    #[allow(unused_variables)] output: crate::output::OperationOutput,
   37     53   
) -> std::result::Result<
   38     54   
    ::aws_smithy_http_server::response::Response,
   39     55   
    ::aws_smithy_http_server::protocol::rest_json_1::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/json",
   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_operation_output::ser_operation_output_output_output(
   53         -
                &output,
   54         -
            )?;
          74  +
            /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_operation_output::ser_operation_output_output_output(&output)?
          75  +
        /* ServerHttpBoundProtocolGenerator.kt:561 */;
          76  +
        /* ServerHttpBoundProtocolGenerator.kt:663 */
   55     77   
        let content_length = payload.len();
   56     78   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     79   
            builder,
   58     80   
            ::http::header::CONTENT_LENGTH,
   59     81   
            content_length,
   60     82   
        );
          83  +
        /* ServerHttpBoundProtocolGenerator.kt:567 */
   61     84   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
          85  +
        /* ServerHttpBoundProtocolGenerator.kt:575 */
   62     86   
        builder.body(body)?
          87  +
        /* ServerHttpBoundProtocolGenerator.kt:433 */
   63     88   
    })
          89  +
    /* ServerHttpBoundProtocolGenerator.kt:421 */
   64     90   
}
   65     91   
          92  +
/* RustType.kt:516 */
   66     93   
#[allow(clippy::unnecessary_wraps)]
          94  +
/* ServerHttpBoundProtocolGenerator.kt:447 */
   67     95   
pub fn ser_operation_http_error(
   68     96   
    error: &crate::error::OperationError,
   69     97   
) -> std::result::Result<
   70     98   
    ::aws_smithy_http_server::response::Response,
   71     99   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   72    100   
> {
         101  +
    /* ServerHttpBoundProtocolGenerator.kt:452 */
   73    102   
    Ok({
         103  +
        /* ServerHttpBoundProtocolGenerator.kt:468 */
   74    104   
        match error {
         105  +
            /* ServerHttpBoundProtocolGenerator.kt:476 */
   75    106   
            crate::error::OperationError::InternalServerError(output) => {
         107  +
                /* ServerHttpBoundProtocolGenerator.kt:477 */
   76    108   
                let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
         109  +
                /* RustType.kt:516 */
   77    110   
                #[allow(unused_mut)]
         111  +
                /* ServerHttpBoundProtocolGenerator.kt:487 */
   78    112   
                let mut builder = ::http::Response::builder();
         113  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   79    114   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   80    115   
                    builder,
   81    116   
                    ::http::header::CONTENT_TYPE,
   82    117   
                    "application/json",
   83    118   
                );
         119  +
                /* ServerHttpBoundProtocolGenerator.kt:597 */
   84    120   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   85    121   
                    builder,
   86    122   
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
   87    123   
                    "InternalServerError",
   88    124   
                );
         125  +
                /* ServerHttpBoundProtocolGenerator.kt:663 */
   89    126   
                let content_length = payload.len();
   90    127   
                builder = ::aws_smithy_http::header::set_response_header_if_absent(
   91    128   
                    builder,
   92    129   
                    ::http::header::CONTENT_LENGTH,
   93    130   
                    content_length,
   94    131   
                );
         132  +
                /* ServerHttpBoundProtocolGenerator.kt:504 */
   95    133   
                builder
   96    134   
                    .status(500)
   97    135   
                    .body(::aws_smithy_http_server::body::to_boxed(payload))?
   98         -
            }
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   99    138   
        }
         139  +
        /* ServerHttpBoundProtocolGenerator.kt:452 */
  100    140   
    })
         141  +
    /* ServerHttpBoundProtocolGenerator.kt:447 */
  101    142   
}
  102    143   
         144  +
/* JsonParserGenerator.kt:148 */
  103    145   
pub(crate) fn de_operation(
  104    146   
    value: &[u8],
  105    147   
    mut builder: crate::input::operation_input_internal::Builder,
  106    148   
) -> ::std::result::Result<
  107    149   
    crate::input::operation_input_internal::Builder,
  108    150   
    ::aws_smithy_json::deserialize::error::DeserializeError,
  109    151   
> {
         152  +
    /* JsonParserGenerator.kt:153 */
  110    153   
    let mut tokens_owned =
  111    154   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
  112    155   
            .peekable();
  113    156   
    let tokens = &mut tokens_owned;
  114    157   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         158  +
    /* JsonParserGenerator.kt:684 */
  115    159   
    loop {
         160  +
        /* JsonParserGenerator.kt:685 */
  116    161   
        match tokens.next().transpose()? {
         162  +
            /* JsonParserGenerator.kt:686 */
  117    163   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
  118    164   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         165  +
                /* JsonParserGenerator.kt:260 */
  119    166   
                match key.to_unescaped()?.as_ref() {
         167  +
                    /* JsonParserGenerator.kt:262 */
  120    168   
                    "message" => {
         169  +
                        /* JsonParserGenerator.kt:272 */
  121    170   
                        builder = builder.set_message(
         171  +
                            /* JsonParserGenerator.kt:354 */
  122    172   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
  123    173   
                                tokens.next(),
  124    174   
                            )?
  125         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
  126         -
                            .transpose()?,
         175  +
                            .map(|s|
         176  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         177  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         178  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         179  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
  127    180   
                        );
         181  +
                        /* JsonParserGenerator.kt:262 */
  128    182   
                    }
  129         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         183  +
                    /* JsonParserGenerator.kt:290 */
         184  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
  130    185   
                }
         186  +
                /* JsonParserGenerator.kt:686 */
  131    187   
            }
         188  +
            /* JsonParserGenerator.kt:695 */
  132    189   
            other => {
  133    190   
                return Err(
  134    191   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
  135    192   
                        "expected object key or end object, found: {:?}",
  136    193   
                        other
  137    194   
                    )),
  138    195   
                )
  139         -
            }
         196  +
            } /* JsonParserGenerator.kt:685 */
  140    197   
        }
         198  +
        /* JsonParserGenerator.kt:684 */
  141    199   
    }
         200  +
    /* JsonParserGenerator.kt:250 */
  142    201   
    if tokens.next().is_some() {
         202  +
        /* JsonParserGenerator.kt:251 */
  143    203   
        return Err(
  144    204   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  145    205   
                "found more JSON tokens after completing parsing",
  146    206   
            ),
  147    207   
        );
         208  +
        /* JsonParserGenerator.kt:250 */
  148    209   
    }
         210  +
    /* JsonParserGenerator.kt:163 */
  149    211   
    Ok(builder)
         212  +
    /* JsonParserGenerator.kt:148 */
  150    213   
}

tmp-codegen-diff/codegen-server-test-python/simple/rust-server-codegen-python/src/protocol_serde/shape_operation_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_operation_output_output_output(
    3      4   
    value: &crate::output::OperationOutput,
    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_operation_output::ser_operation_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_operation_output_output(
   13     19   
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
   14     20   
    input: &crate::output::OperationOutput,
   15     21   
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          22  +
    /* JsonSerializerGenerator.kt:382 */
   16     23   
    if let Some(var_1) = &input.message {
          24  +
        /* JsonSerializerGenerator.kt:423 */
   17     25   
        object.key("message").string(var_1.as_str());
          26  +
        /* JsonSerializerGenerator.kt:382 */
   18     27   
    }
          28  +
    /* JsonSerializerGenerator.kt:372 */
   19     29   
    Ok(())
          30  +
    /* JsonSerializerGenerator.kt:358 */
   20     31   
}