Server Test Typescript

Server Test Typescript

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test-typescript/pokemon-service-server-sdk/rust-server-codegen-typescript/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 [`PokemonService`].
    3      4   
///
    4      5   
/// Constructed via [`PokemonService::builder`].
    5      6   
pub struct PokemonServiceBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    check_health: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    do_nothing: Option<::aws_smithy_http_server::routing::Route<Body>>,
    8      9   
    get_pokemon_species: Option<::aws_smithy_http_server::routing::Route<Body>>,
    9     10   
    get_server_statistics: Option<::aws_smithy_http_server::routing::Route<Body>>,
   10     11   
    layer: L,
   11     12   
    http_plugin: HttpPl,
@@ -1074,1075 +1133,1135 @@
 1094   1095   
            "com.aws.example.ts",
 1095   1096   
            "PokemonService",
 1096   1097   
        );
 1097   1098   
 1098   1099   
    const VERSION: Option<&'static str> = Some("2021-12-01");
 1099   1100   
 1100   1101   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
 1101   1102   
 1102   1103   
    type Operations = Operation;
 1103   1104   
}
        1105  +
/* ServiceConfigGenerator.kt:178 */
 1104   1106   
/// Configuration for the [`PokemonService`]. This is the central place where to register and
 1105   1107   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
 1106   1108   
///
 1107   1109   
/// ```rust,no_run
 1108   1110   
/// # use pokemon_service_server_sdk::PokemonServiceConfig;
 1109   1111   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
 1110   1112   
/// # use ::tower::layer::util::Identity;
 1111   1113   
/// # let authentication_plugin = IdentityPlugin;
 1112   1114   
/// # let authorization_plugin = IdentityPlugin;
 1113   1115   
/// # let server_request_id_provider_layer = Identity::new();
@@ -1195,1197 +1254,1257 @@
 1215   1217   
 1216   1218   
    /// Build the configuration.
 1217   1219   
    pub fn build(self) -> super::PokemonServiceConfig<L, H, M> {
 1218   1220   
        super::PokemonServiceConfig {
 1219   1221   
            layers: self.layers,
 1220   1222   
            http_plugins: self.http_plugins,
 1221   1223   
            model_plugins: self.model_plugins,
 1222   1224   
        }
 1223   1225   
    }
 1224   1226   
}
        1227  +
/* ScopeMacroGenerator.kt:81 */
 1225   1228   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
 1226   1229   
///
 1227   1230   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
 1228   1231   
/// of the service and any operations _not_ specified will be placed in the opposing group.
 1229   1232   
///
 1230   1233   
/// # Example
 1231   1234   
///
 1232   1235   
/// ```rust
 1233   1236   
/// scope! {
 1234   1237   
///     /// Includes [`CheckHealth`], excluding all other operations.

tmp-codegen-diff/codegen-server-test-typescript/pokemon-service-server-sdk/rust-server-codegen-typescript/src/ts_operation_adaptor.rs

@@ -1,1 +60,64 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* TsServerOperationHandlerGenerator.kt:45 */
    2      3   
/// Typescript handler for operation `GetPokemonSpecies`.
    3      4   
pub(crate) async fn get_pokemon_species(
    4      5   
    input: crate::input::GetPokemonSpeciesInput,
    5      6   
    handlers: ::aws_smithy_http_server::Extension<crate::ts_server_application::Handlers>,
    6      7   
) -> std::result::Result<crate::output::GetPokemonSpeciesOutput, crate::error::GetPokemonSpeciesError>
    7      8   
{
    8      9   
    handlers
    9     10   
        .get_pokemon_species
   10     11   
        .call_async::<::napi::bindgen_prelude::Promise<crate::output::GetPokemonSpeciesOutput>>(
   11     12   
            input,
   12     13   
        )
   13     14   
        .await?
   14     15   
        .await
   15     16   
        .map_err(|e| e.into())
   16     17   
}
   17     18   
          19  +
/* TsServerOperationHandlerGenerator.kt:45 */
   18     20   
/// Typescript handler for operation `CheckHealth`.
   19     21   
pub(crate) async fn check_health(
   20     22   
    input: crate::input::CheckHealthInput,
   21     23   
    handlers: ::aws_smithy_http_server::Extension<crate::ts_server_application::Handlers>,
   22     24   
) -> std::result::Result<crate::output::CheckHealthOutput, crate::error::CheckHealthError> {
   23     25   
    handlers
   24     26   
        .check_health
   25     27   
        .call_async::<::napi::bindgen_prelude::Promise<crate::output::CheckHealthOutput>>(input)
   26     28   
        .await?
   27     29   
        .await
   28     30   
        .map_err(|e| e.into())
   29     31   
}
   30     32   
          33  +
/* TsServerOperationHandlerGenerator.kt:45 */
   31     34   
/// Typescript handler for operation `DoNothing`.
   32     35   
pub(crate) async fn do_nothing(
   33     36   
    input: crate::input::DoNothingInput,
   34     37   
    handlers: ::aws_smithy_http_server::Extension<crate::ts_server_application::Handlers>,
   35     38   
) -> std::result::Result<crate::output::DoNothingOutput, crate::error::DoNothingError> {
   36     39   
    handlers
   37     40   
        .do_nothing
   38     41   
        .call_async::<::napi::bindgen_prelude::Promise<crate::output::DoNothingOutput>>(input)
   39     42   
        .await?
   40     43   
        .await
   41     44   
        .map_err(|e| e.into())
   42     45   
}
   43     46   
          47  +
/* TsServerOperationHandlerGenerator.kt:45 */
   44     48   
/// Typescript handler for operation `GetServerStatistics`.
   45     49   
pub(crate) async fn get_server_statistics(
   46     50   
    input: crate::input::GetServerStatisticsInput,
   47     51   
    handlers: ::aws_smithy_http_server::Extension<crate::ts_server_application::Handlers>,
   48     52   
) -> std::result::Result<
   49     53   
    crate::output::GetServerStatisticsOutput,
   50     54   
    crate::error::GetServerStatisticsError,
   51     55   
> {
   52     56   
    handlers
   53     57   
        .get_server_statistics

tmp-codegen-diff/codegen-server-test-typescript/pokemon-service-server-sdk/rust-server-codegen-typescript/src/ts_server_application.rs

@@ -1,1 +174,240 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* TsApplicationGenerator.kt:62 */
    2      3   
use napi_derive::napi;
           4  +
/* RustType.kt:516 */
    3      5   
#[derive(::std::clone::Clone)]
           6  +
/* TsApplicationGenerator.kt:73 */
    4      7   
pub struct Handlers {
           8  +
    /* TsApplicationGenerator.kt:78 */
    5      9   
    pub(crate) check_health: ::napi::threadsafe_function::ThreadsafeFunction<
    6     10   
        crate::input::CheckHealthInput,
    7     11   
        ::napi::threadsafe_function::ErrorStrategy::Fatal,
    8     12   
    >,
          13  +
    /* TsApplicationGenerator.kt:78 */
    9     14   
    pub(crate) do_nothing: ::napi::threadsafe_function::ThreadsafeFunction<
   10     15   
        crate::input::DoNothingInput,
   11     16   
        ::napi::threadsafe_function::ErrorStrategy::Fatal,
   12     17   
    >,
          18  +
    /* TsApplicationGenerator.kt:78 */
   13     19   
    pub(crate) get_pokemon_species: ::napi::threadsafe_function::ThreadsafeFunction<
   14     20   
        crate::input::GetPokemonSpeciesInput,
   15     21   
        ::napi::threadsafe_function::ErrorStrategy::Fatal,
   16     22   
    >,
          23  +
    /* TsApplicationGenerator.kt:78 */
   17     24   
    pub(crate) get_server_statistics: ::napi::threadsafe_function::ThreadsafeFunction<
   18     25   
        crate::input::GetServerStatisticsInput,
   19     26   
        ::napi::threadsafe_function::ErrorStrategy::Fatal,
   20     27   
    >,
          28  +
    /* TsApplicationGenerator.kt:73 */
   21     29   
}
          30  +
/* RustType.kt:516 */
   22     31   
#[napi(object)]
          32  +
/* TsApplicationGenerator.kt:90 */
   23     33   
pub struct TsHandlers {
          34  +
    /* TsApplicationGenerator.kt:96 */
   24     35   
    #[napi(ts_type = "(input: CheckHealthInput) => Promise<CheckHealthOutput>")]
   25     36   
    pub check_health: ::napi::JsFunction,
          37  +
    /* TsApplicationGenerator.kt:96 */
   26     38   
    #[napi(ts_type = "(input: DoNothingInput) => Promise<DoNothingOutput>")]
   27     39   
    pub do_nothing: ::napi::JsFunction,
          40  +
    /* TsApplicationGenerator.kt:96 */
   28     41   
    #[napi(ts_type = "(input: GetPokemonSpeciesInput) => Promise<GetPokemonSpeciesOutput>")]
   29     42   
    pub get_pokemon_species: ::napi::JsFunction,
          43  +
    /* TsApplicationGenerator.kt:96 */
   30     44   
    #[napi(ts_type = "(input: GetServerStatisticsInput) => Promise<GetServerStatisticsOutput>")]
   31     45   
    pub get_server_statistics: ::napi::JsFunction,
          46  +
    /* TsApplicationGenerator.kt:90 */
   32     47   
}
          48  +
/* RustType.kt:516 */
   33     49   
#[napi]
          50  +
/* TsApplicationGenerator.kt:109 */
   34     51   
pub struct App {
   35     52   
    handlers: Handlers,
   36     53   
}
          54  +
/* RustType.kt:516 */
   37     55   
#[napi]
          56  +
/* TsApplicationGenerator.kt:117 */
   38     57   
impl App {
          58  +
    /* RustType.kt:516 */
   39     59   
    #[napi(constructor)]
          60  +
    /* TsApplicationGenerator.kt:125 */
   40     61   
    pub fn create(ts_handlers: TsHandlers) -> ::napi::Result<Self> {
          62  +
        /* TsApplicationGenerator.kt:133 */
   41     63   
        let check_health: ::napi::threadsafe_function::ThreadsafeFunction<
   42     64   
            crate::input::CheckHealthInput,
   43     65   
            ::napi::threadsafe_function::ErrorStrategy::Fatal,
   44     66   
        > = ts_handlers
   45     67   
            .check_health
   46     68   
            .create_threadsafe_function(0, |ctx| Ok(vec![ctx.value]))?;
          69  +
        /* TsApplicationGenerator.kt:133 */
   47     70   
        let do_nothing: ::napi::threadsafe_function::ThreadsafeFunction<
   48     71   
            crate::input::DoNothingInput,
   49     72   
            ::napi::threadsafe_function::ErrorStrategy::Fatal,
   50     73   
        > = ts_handlers
   51     74   
            .do_nothing
   52     75   
            .create_threadsafe_function(0, |ctx| Ok(vec![ctx.value]))?;
          76  +
        /* TsApplicationGenerator.kt:133 */
   53     77   
        let get_pokemon_species: ::napi::threadsafe_function::ThreadsafeFunction<
   54     78   
            crate::input::GetPokemonSpeciesInput,
   55     79   
            ::napi::threadsafe_function::ErrorStrategy::Fatal,
   56     80   
        > = ts_handlers
   57     81   
            .get_pokemon_species
   58     82   
            .create_threadsafe_function(0, |ctx| Ok(vec![ctx.value]))?;
          83  +
        /* TsApplicationGenerator.kt:133 */
   59     84   
        let get_server_statistics: ::napi::threadsafe_function::ThreadsafeFunction<
   60     85   
            crate::input::GetServerStatisticsInput,
   61     86   
            ::napi::threadsafe_function::ErrorStrategy::Fatal,
   62     87   
        > = ts_handlers
   63     88   
            .get_server_statistics
   64     89   
            .create_threadsafe_function(0, |ctx| Ok(vec![ctx.value]))?;
          90  +
        /* TsApplicationGenerator.kt:142 */
   65     91   
        let handlers = Handlers {
   66         -
            check_health: check_health.clone(),
   67         -
            do_nothing: do_nothing.clone(),
          92  +
            /* TsApplicationGenerator.kt:145 */ check_health: check_health.clone(),
          93  +
            /* TsApplicationGenerator.kt:145 */ do_nothing: do_nothing.clone(),
          94  +
            /* TsApplicationGenerator.kt:145 */
   68     95   
            get_pokemon_species: get_pokemon_species.clone(),
          96  +
            /* TsApplicationGenerator.kt:145 */
   69     97   
            get_server_statistics: get_server_statistics.clone(),
          98  +
            /* TsApplicationGenerator.kt:147 */
   70     99   
        };
         100  +
        /* TsApplicationGenerator.kt:148 */
   71    101   
        Ok(Self { handlers })
         102  +
        /* TsApplicationGenerator.kt:125 */
   72    103   
    }
         104  +
    /* RustType.kt:516 */
   73    105   
    #[napi]
         106  +
    /* TsApplicationGenerator.kt:154 */
   74    107   
    pub fn start(&self, socket: &TsSocket) -> ::napi::Result<()> {
         108  +
        /* TsApplicationGenerator.kt:158 */
   75    109   
        let plugins = ::aws_smithy_http_server::plugin::PluginPipeline::new();
   76    110   
        let builder = crate::service::PokemonService::builder_with_plugins(plugins);
         111  +
        /* TsApplicationGenerator.kt:167 */
   77    112   
        let builder = builder.check_health(crate::ts_operation_adaptor::check_health);
         113  +
        /* TsApplicationGenerator.kt:167 */
   78    114   
        let builder = builder.do_nothing(crate::ts_operation_adaptor::do_nothing);
         115  +
        /* TsApplicationGenerator.kt:167 */
   79    116   
        let builder = builder.get_pokemon_species(crate::ts_operation_adaptor::get_pokemon_species);
         117  +
        /* TsApplicationGenerator.kt:167 */
   80    118   
        let builder =
   81    119   
            builder.get_server_statistics(crate::ts_operation_adaptor::get_server_statistics);
         120  +
        /* TsApplicationGenerator.kt:169 */
   82    121   
        let app = builder
   83    122   
            .build()
   84    123   
            .expect("failed to build instance of PokemonService")
   85    124   
            .layer(&::aws_smithy_http_server::AddExtensionLayer::new(
   86    125   
                self.handlers.clone(),
   87    126   
            ));
   88    127   
        let service = ::tower::util::BoxCloneService::new(app);
   89    128   
        start_hyper_worker(socket, service).expect("failed to start the hyper server");
   90    129   
        Ok(())
         130  +
        /* TsApplicationGenerator.kt:154 */
   91    131   
    }
         132  +
    /* TsApplicationGenerator.kt:117 */
   92    133   
}
         134  +
/* RustType.kt:516 */
   93    135   
#[napi]
         136  +
/* RustType.kt:516 */
   94    137   
#[derive(::std::fmt::Debug)]
         138  +
/* TsApplicationGenerator.kt:185 */
   95    139   
pub struct TsSocket(::socket2::Socket);
         140  +
/* RustType.kt:516 */
   96    141   
#[napi]
         142  +
/* TsApplicationGenerator.kt:193 */
   97    143   
impl TsSocket {
         144  +
    /* TsApplicationGenerator.kt:194 */
   98    145   
    /// Create a new UNIX `Socket` from an address, port and backlog.
   99    146   
    /// If not specified, the backlog defaults to 1024 connections.
         147  +
    /* RustType.kt:516 */
  100    148   
    #[napi(constructor)]
         149  +
    /* TsApplicationGenerator.kt:201 */
  101    150   
    pub fn new(address: String, port: i32, backlog: Option<i32>) -> ::napi::Result<Self> {
         151  +
        /* TsApplicationGenerator.kt:205 */
  102    152   
        let socket = Self::new_socket(address, port, backlog)
  103    153   
            .map_err(|e| ::napi::Error::from_reason(e.to_string()))?;
  104    154   
        Ok(Self(socket))
         155  +
        /* TsApplicationGenerator.kt:201 */
  105    156   
    }
         157  +
    /* TsApplicationGenerator.kt:214 */
  106    158   
    pub fn new_socket(
  107    159   
        address: String,
  108    160   
        port: i32,
  109    161   
        backlog: Option<i32>,
  110    162   
    ) -> Result<::socket2::Socket, Box<dyn std::error::Error>> {
         163  +
        /* TsApplicationGenerator.kt:218 */
  111    164   
        let address: std::net::SocketAddr = format!("{}:{}", address, port).parse()?;
  112    165   
        let domain = if address.is_ipv6() {
  113    166   
            ::socket2::Domain::IPV6
  114    167   
        } else {
  115    168   
            ::socket2::Domain::IPV4
  116    169   
        };
  117    170   
        let socket = ::socket2::Socket::new(
  118    171   
            domain,
  119    172   
            ::socket2::Type::STREAM,
  120    173   
            Some(::socket2::Protocol::TCP),
  121    174   
        )?;
  122    175   
        // Set value for the `SO_REUSEPORT` and `SO_REUSEADDR` options on this socket.
  123    176   
        // This indicates that further calls to `bind` may allow reuse of local
  124    177   
        // addresses. For IPv4 sockets this means that a socket may bind even when
  125    178   
        // there's a socket already listening on this port.
  126    179   
        socket.set_reuse_port(true)?;
  127    180   
        socket.set_reuse_address(true)?;
  128    181   
        socket.bind(&address.into())?;
  129    182   
        socket.listen(backlog.unwrap_or(1024))?;
  130    183   
        Ok(socket)
         184  +
        /* TsApplicationGenerator.kt:214 */
  131    185   
    }
         186  +
    /* TsApplicationGenerator.kt:241 */
  132    187   
    /// Clone the inner socket allowing it to be shared between multiple
  133    188   
    /// Nodejs processes.
         189  +
    /* RustType.kt:516 */
  134    190   
    #[napi]
         191  +
    /* TsApplicationGenerator.kt:248 */
  135    192   
    pub fn try_clone(&self) -> ::napi::Result<Self> {
         193  +
        /* TsApplicationGenerator.kt:252 */
  136    194   
        Ok(TsSocket(
  137    195   
            self.0
  138    196   
                .try_clone()
  139    197   
                .map_err(|e| ::napi::Error::from_reason(e.to_string()))?,
  140    198   
        ))
         199  +
        /* TsApplicationGenerator.kt:248 */
  141    200   
    }
         201  +
    /* TsApplicationGenerator.kt:193 */
  142    202   
}
         203  +
/* TsApplicationGenerator.kt:265 */
  143    204   
impl TsSocket {
         205  +
    /* TsApplicationGenerator.kt:266 */
  144    206   
    pub fn to_raw_socket(&self) -> ::napi::Result<::socket2::Socket> {
  145    207   
        self.0
  146    208   
            .try_clone()
  147    209   
            .map_err(|e| ::napi::Error::from_reason(e.to_string()))
  148    210   
    }
         211  +
    /* TsApplicationGenerator.kt:265 */
  149    212   
}
         213  +
/* TsApplicationGenerator.kt:281 */
  150    214   
pub fn start_hyper_worker(
  151    215   
    socket: &TsSocket,
  152    216   
    app: ::tower::util::BoxCloneService<
  153    217   
        ::http::Request<::aws_smithy_http_server::body::Body>,
  154    218   
        ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  155    219   
        std::convert::Infallible,
  156    220   
    >,
  157    221   
) -> ::napi::Result<()> {
         222  +
    /* TsApplicationGenerator.kt:294 */
  158    223   
    let server = ::hyper::Server::from_tcp(
  159    224   
        socket
  160    225   
            .to_raw_socket()?
  161    226   
            .try_into()
  162    227   
            .expect("Unable to convert socket2::Socket into std::net::TcpListener"),
  163    228   
    )
  164    229   
    .expect("Unable to create hyper server from shared socket")
  165    230   
    .serve(::aws_smithy_http_server::routing::IntoMakeService::new(app));
  166    231   
  167    232   
    let handle = ::tokio::runtime::Handle::current();
  168    233   
    handle.spawn(async move {
  169    234   
        // Process each socket concurrently.
  170    235   
        server.await
  171    236   
    });
  172    237   
  173    238   
    Ok(())
         239  +
    /* TsApplicationGenerator.kt:281 */
  174    240   
}

tmp-codegen-diff/codegen-server-test-typescript/pokemon-service-server-sdk/rust-server-codegen-typescript/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-typescript/simple/rust-server-codegen-typescript/build.rs

@@ -1,1 +4,5 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* TsServerCodegenDecorator.kt:47 */
    2      3   
fn main() {
    3      4   
    ::napi_build::setup();
    4      5   
}

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/package.json

@@ -1,0 +30,30 @@
    1         -
{
           1  +
/* TsServerCodegenDecorator.kt:102 */{
    2      2   
                "name": "@amzn/simple",
    3      3   
                "version": "0.0.1",
    4      4   
                "main": "index.js",
    5      5   
                "types": "index.d.ts",
    6      6   
                "napi": {
    7      7   
                    "name": "simple",
    8      8   
                    "triple": {}
    9      9   
                },
   10     10   
                "devDependencies": {
   11     11   
                    "@napi-rs/cli": ">=2",

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/src/error.rs

@@ -1,1 +138,250 @@
    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()
   25     54   
            }
          55  +
            /* ServerOperationErrorGenerator.kt:139 */
   26     56   
        }
          57  +
        /* ServerOperationErrorGenerator.kt:93 */
          58  +
    }
          59  +
    /* ServerOperationErrorGenerator.kt:83 */
   27     60   
}
          61  +
/* ServerOperationErrorGenerator.kt:100 */
   28     62   
impl ::std::error::Error for 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  +
/* TsServerOperationErrorGenerator.kt:34 */
   41     91   
impl ::std::convert::From<::napi::Error> for crate::error::OperationError {
   42     92   
    fn from(variant: ::napi::Error) -> crate::error::OperationError {
   43     93   
        crate::error::InternalServerError {
   44     94   
            message: variant.to_string(),
   45     95   
        }
   46     96   
        .into()
   47     97   
    }
   48     98   
}
   49     99   
         100  +
/* RustType.kt:516 */
   50    101   
#[::napi_derive::napi(constructor)]
         102  +
/* StructureGenerator.kt:197 */
   51    103   
#[allow(missing_docs)] // documentation missing in model
         104  +
/* RustType.kt:516 */
   52    105   
#[derive(
   53    106   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   54    107   
)]
   55         -
pub struct InternalServerError {
         108  +
pub /* StructureGenerator.kt:201 */ struct InternalServerError {
         109  +
    /* StructureGenerator.kt:231 */
   56    110   
    #[allow(missing_docs)] // documentation missing in model
   57    111   
    pub message: ::std::string::String,
         112  +
    /* StructureGenerator.kt:201 */
   58    113   
}
         114  +
/* ErrorImplGenerator.kt:99 */
   59    115   
impl InternalServerError {
         116  +
    /* ErrorImplGenerator.kt:128 */
   60    117   
    /// Returns the error message.
   61    118   
    pub fn message(&self) -> &str {
   62    119   
        &self.message
   63    120   
    }
         121  +
    /* ErrorImplGenerator.kt:141 */
   64    122   
    #[doc(hidden)]
   65    123   
    /// Returns the error name.
   66    124   
    pub fn name(&self) -> &'static str {
   67    125   
        "InternalServerError"
   68    126   
    }
         127  +
    /* ErrorImplGenerator.kt:99 */
   69    128   
}
         129  +
/* ErrorImplGenerator.kt:153 */
   70    130   
impl ::std::fmt::Display for InternalServerError {
         131  +
    /* ErrorImplGenerator.kt:154 */
   71    132   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         133  +
        /* ErrorImplGenerator.kt:161 */
   72    134   
        ::std::write!(f, "InternalServerError")?;
         135  +
        /* ErrorImplGenerator.kt:166 */
   73    136   
        {
         137  +
            /* ErrorImplGenerator.kt:167 */
   74    138   
            ::std::write!(f, ": {}", &self.message)?;
         139  +
            /* ErrorImplGenerator.kt:166 */
   75    140   
        }
         141  +
        /* ErrorImplGenerator.kt:171 */
   76    142   
        Ok(())
         143  +
        /* ErrorImplGenerator.kt:154 */
   77    144   
    }
         145  +
    /* ErrorImplGenerator.kt:153 */
   78    146   
}
         147  +
/* ErrorImplGenerator.kt:175 */
   79    148   
impl ::std::error::Error for InternalServerError {}
         149  +
/* ServerCodegenVisitor.kt:370 */
   80    150   
impl InternalServerError {
   81         -
    /// Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         151  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`InternalServerError`](crate::error::InternalServerError).
         152  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   82    153   
    pub fn builder() -> crate::error::internal_server_error::Builder {
         154  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   83    155   
        crate::error::internal_server_error::Builder::default()
         156  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   84    157   
    }
         158  +
    /* ServerCodegenVisitor.kt:370 */
   85    159   
}
   86         -
/// See [`InternalServerError`](crate::error::InternalServerError).
         160  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`InternalServerError`](crate::error::InternalServerError).
   87    161   
pub mod internal_server_error {
   88    162   
         163  +
    /* RustType.kt:516 */
   89    164   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
   90         -
    /// Holds one variant for each of the ways the builder can fail.
   91         -
         165  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
         166  +
    /* ServerBuilderConstraintViolations.kt:75 */
   92    167   
    #[allow(clippy::enum_variant_names)]
   93    168   
    pub enum ConstraintViolation {
   94         -
        /// `message` was not provided but it is required when building `InternalServerError`.
         169  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`message` was not provided but it is required when building `InternalServerError`.
         170  +
        /* ServerBuilderConstraintViolations.kt:143 */
   95    171   
        MissingMessage,
         172  +
        /* ServerBuilderConstraintViolations.kt:75 */
   96    173   
    }
         174  +
    /* ServerBuilderConstraintViolations.kt:117 */
   97    175   
    impl ::std::fmt::Display for ConstraintViolation {
         176  +
        /* ServerBuilderConstraintViolations.kt:118 */
   98    177   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         178  +
            /* ServerBuilderConstraintViolations.kt:119 */
   99    179   
            match self {
  100         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
  101         -
            }
         180  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `InternalServerError`"),
         181  +
            /* ServerBuilderConstraintViolations.kt:119 */}
         182  +
            /* ServerBuilderConstraintViolations.kt:118 */
  102    183   
        }
         184  +
        /* ServerBuilderConstraintViolations.kt:117 */
  103    185   
    }
         186  +
    /* ServerBuilderConstraintViolations.kt:84 */
  104    187   
    impl ::std::error::Error for ConstraintViolation {}
         188  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:254 */
  105    189   
    impl ::std::convert::TryFrom<Builder> for crate::error::InternalServerError {
  106    190   
        type Error = ConstraintViolation;
  107    191   
  108    192   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  109    193   
            builder.build()
  110    194   
        }
  111    195   
    }
  112         -
    /// A builder for [`InternalServerError`](crate::error::InternalServerError).
         196  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`InternalServerError`](crate::error::InternalServerError).
         197  +
    /* RustType.kt:516 */
  113    198   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         199  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  114    200   
    pub struct Builder {
         201  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
  115    202   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         203  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
  116    204   
    }
         205  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  117    206   
    impl Builder {
         207  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
  118    208   
        #[allow(missing_docs)] // documentation missing in model
         209  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  119    210   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  120         -
            self.message = Some(input);
         211  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         212  +
            self.message =
         213  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */Some(
         214  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         215  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:246 */)
         216  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
  121    217   
            self
         218  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
  122    219   
        }
  123         -
        /// Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
  124         -
        ///
         220  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`InternalServerError`](crate::error::InternalServerError).
         221  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:152 */
  125    222   
        /// The builder fails to construct a [`InternalServerError`](crate::error::InternalServerError) if you do not provide a value for all non-`Option`al members.
  126    223   
        ///
         224  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
  127    225   
        pub fn build(self) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  128    226   
            self.build_enforcing_required_and_enum_traits()
  129    227   
        }
         228  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
  130    229   
        fn build_enforcing_required_and_enum_traits(
  131    230   
            self,
  132    231   
        ) -> Result<crate::error::InternalServerError, ConstraintViolation> {
  133         -
            Ok(crate::error::InternalServerError {
  134         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  135         -
            })
  136         -
        }
         232  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         233  +
            Ok(
         234  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         235  +
                crate::error::InternalServerError {
         236  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
         237  +
                    message: self
         238  +
                        .message
         239  +
                        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:202 */
         240  +
                        .ok_or(ConstraintViolation::MissingMessage)?,
         241  +
                    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
         242  +
                }, /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:175 */
         243  +
            )
         244  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
         245  +
        }
         246  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
  137    247   
    }
         248  +
         249  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  138    250   
}

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/src/input.rs

@@ -1,1 +88,145 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[::napi_derive::napi(object)]
           4  +
/* StructureGenerator.kt:197 */
    3      5   
#[allow(missing_docs)] // documentation missing in model
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(
    5      8   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    6      9   
)]
    7         -
pub struct OperationInput {
          10  +
pub /* StructureGenerator.kt:201 */ struct OperationInput {
          11  +
    /* StructureGenerator.kt:231 */
    8     12   
    #[allow(missing_docs)] // documentation missing in model
    9     13   
    pub message: ::std::option::Option<::std::string::String>,
          14  +
    /* StructureGenerator.kt:201 */
   10     15   
}
          16  +
/* StructureGenerator.kt:135 */
   11     17   
impl OperationInput {
          18  +
    /* StructureGenerator.kt:231 */
   12     19   
    #[allow(missing_docs)] // documentation missing in model
          20  +
                           /* StructureGenerator.kt:166 */
   13     21   
    pub fn message(&self) -> ::std::option::Option<&str> {
          22  +
        /* StructureGenerator.kt:169 */
   14     23   
        self.message.as_deref()
          24  +
        /* StructureGenerator.kt:166 */
   15     25   
    }
          26  +
    /* StructureGenerator.kt:135 */
   16     27   
}
          28  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
   17     29   
impl crate::constrained::Constrained for crate::input::OperationInput {
   18     30   
    type Unconstrained = crate::input::operation_input_internal::Builder;
   19     31   
}
          32  +
/* ServerCodegenVisitor.kt:370 */
   20     33   
impl OperationInput {
   21         -
    /// Creates a new builder-style object to manufacture [`OperationInput`](crate::input::OperationInput).
          34  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`OperationInput`](crate::input::OperationInput).
          35  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   22     36   
    pub fn builder() -> crate::input::operation_input::Builder {
          37  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   23     38   
        crate::input::operation_input::Builder::default()
          39  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   24     40   
    }
          41  +
    /* ServerCodegenVisitor.kt:370 */
   25     42   
}
   26         -
/// See [`OperationInput`](crate::input::OperationInput).
          43  +
/// /* ServerBuilderGenerator.kt:171 */See [`OperationInput`](crate::input::OperationInput).
   27     44   
pub(crate) mod operation_input_internal {
   28     45   
          46  +
    /* ServerBuilderGenerator.kt:461 */
   29     47   
    impl ::std::convert::From<Builder> for crate::input::OperationInput {
   30     48   
        fn from(builder: Builder) -> Self {
   31     49   
            builder.build()
   32     50   
        }
   33     51   
    }
   34         -
    /// A builder for [`OperationInput`](crate::input::OperationInput).
          52  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`OperationInput`](crate::input::OperationInput).
          53  +
    /* RustType.kt:516 */
   35     54   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          55  +
    /* ServerBuilderGenerator.kt:211 */
   36     56   
    pub(crate) struct Builder {
          57  +
        /* ServerBuilderGenerator.kt:308 */
   37     58   
        pub(crate) message: ::std::option::Option<::std::string::String>,
          59  +
        /* ServerBuilderGenerator.kt:211 */
   38     60   
    }
          61  +
    /* ServerBuilderGenerator.kt:215 */
   39     62   
    impl Builder {
          63  +
        /* ServerBuilderGenerator.kt:426 */
   40     64   
        #[allow(missing_docs)] // documentation missing in model
          65  +
                               /* ServerBuilderGenerator.kt:428 */
   41     66   
        pub(crate) fn set_message(
   42     67   
            mut self,
   43     68   
            input: Option<impl ::std::convert::Into<::std::string::String>>,
   44     69   
        ) -> Self {
          70  +
            /* ServerBuilderGenerator.kt:429 */
   45     71   
            self.message = input.map(|v| v.into());
   46     72   
            self
          73  +
            /* ServerBuilderGenerator.kt:428 */
   47     74   
        }
   48         -
        /// Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
          75  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
          76  +
        /* ServerBuilderGenerator.kt:271 */
   49     77   
        pub fn build(self) -> crate::input::OperationInput {
   50     78   
            self.build_enforcing_all_constraints()
   51     79   
        }
          80  +
        /* ServerBuilderGenerator.kt:283 */
   52     81   
        fn build_enforcing_all_constraints(self) -> crate::input::OperationInput {
          82  +
            /* ServerBuilderGenerator.kt:542 */
   53     83   
            crate::input::OperationInput {
          84  +
                /* ServerBuilderGenerator.kt:546 */
   54     85   
                message: self.message,
          86  +
                /* ServerBuilderGenerator.kt:542 */
   55     87   
            }
          88  +
            /* ServerBuilderGenerator.kt:283 */
   56     89   
        }
          90  +
        /* ServerBuilderGenerator.kt:215 */
   57     91   
    }
          92  +
          93  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   58     94   
}
   59         -
/// See [`OperationInput`](crate::input::OperationInput).
          95  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`OperationInput`](crate::input::OperationInput).
   60     96   
pub mod operation_input {
   61     97   
          98  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
   62     99   
    impl ::std::convert::From<Builder> for crate::input::OperationInput {
   63    100   
        fn from(builder: Builder) -> Self {
   64    101   
            builder.build()
   65    102   
        }
   66    103   
    }
   67         -
    /// A builder for [`OperationInput`](crate::input::OperationInput).
         104  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`OperationInput`](crate::input::OperationInput).
         105  +
    /* RustType.kt:516 */
   68    106   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         107  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   69    108   
    pub struct Builder {
         109  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
   70    110   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         111  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   71    112   
    }
         113  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   72    114   
    impl Builder {
         115  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
   73    116   
        #[allow(missing_docs)] // documentation missing in model
         117  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   74    118   
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
   75         -
            self.message = input;
         119  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
         120  +
            self.message =
         121  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
         122  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
   76    123   
            self
         124  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   77    125   
        }
   78         -
        /// Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         126  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`OperationInput`](crate::input::OperationInput).
         127  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
   79    128   
        pub fn build(self) -> crate::input::OperationInput {
   80    129   
            self.build_enforcing_required_and_enum_traits()
   81    130   
        }
         131  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   82    132   
        fn build_enforcing_required_and_enum_traits(self) -> crate::input::OperationInput {
         133  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   83    134   
            crate::input::OperationInput {
         135  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
   84    136   
                message: self.message,
         137  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   85    138   
            }
         139  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   86    140   
        }
         141  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   87    142   
    }
         143  +
         144  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   88    145   
}

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/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 +245,253 @@
  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   
         238  +
/* RustModule.kt:172 */
  232    239   
mod service;
  233    240   
  234    241   
pub mod ts_operation_adaptor;
  235    242   
  236         -
/// Ts server and application implementation.
         243  +
/// /* TsServerModuleDocProvider.kt:21 */Ts server and application implementation.
  237    244   
pub mod ts_server_application;
  238    245   
  239         -
/// Data primitives referenced by other data types.
         246  +
/// /* ServerRustModule.kt:55 */Data primitives referenced by other data types.
  240    247   
pub mod types;
  241    248   
  242         -
/// Constrained types for constrained shapes.
         249  +
/// /* ServerRustModule.kt:55 */Constrained types for constrained shapes.
         250  +
/* RustModule.kt:172 */
  243    251   
mod constrained;
  244    252   
  245    253   
pub(crate) mod protocol_serde;

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/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-typescript/simple/rust-server-codegen-typescript/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-typescript/simple/rust-server-codegen-typescript/src/output.rs

@@ -1,1 +52,89 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* RustType.kt:516 */
    2      3   
#[::napi_derive::napi(object)]
           4  +
/* StructureGenerator.kt:197 */
    3      5   
#[allow(missing_docs)] // documentation missing in model
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(
    5      8   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    6      9   
)]
    7         -
pub struct OperationOutput {
          10  +
pub /* StructureGenerator.kt:201 */ struct OperationOutput {
          11  +
    /* StructureGenerator.kt:231 */
    8     12   
    #[allow(missing_docs)] // documentation missing in model
    9     13   
    pub message: ::std::option::Option<::std::string::String>,
          14  +
    /* StructureGenerator.kt:201 */
   10     15   
}
          16  +
/* StructureGenerator.kt:135 */
   11     17   
impl OperationOutput {
          18  +
    /* StructureGenerator.kt:231 */
   12     19   
    #[allow(missing_docs)] // documentation missing in model
          20  +
                           /* StructureGenerator.kt:166 */
   13     21   
    pub fn message(&self) -> ::std::option::Option<&str> {
          22  +
        /* StructureGenerator.kt:169 */
   14     23   
        self.message.as_deref()
          24  +
        /* StructureGenerator.kt:166 */
   15     25   
    }
          26  +
    /* StructureGenerator.kt:135 */
   16     27   
}
          28  +
/* ServerCodegenVisitor.kt:370 */
   17     29   
impl OperationOutput {
   18         -
    /// Creates a new builder-style object to manufacture [`OperationOutput`](crate::output::OperationOutput).
          30  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:211 */Creates a new builder-style object to manufacture [`OperationOutput`](crate::output::OperationOutput).
          31  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   19     32   
    pub fn builder() -> crate::output::operation_output::Builder {
          33  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:213 */
   20     34   
        crate::output::operation_output::Builder::default()
          35  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:212 */
   21     36   
    }
          37  +
    /* ServerCodegenVisitor.kt:370 */
   22     38   
}
   23         -
/// See [`OperationOutput`](crate::output::OperationOutput).
          39  +
/// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:110 */See [`OperationOutput`](crate::output::OperationOutput).
   24     40   
pub mod operation_output {
   25     41   
          42  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:269 */
   26     43   
    impl ::std::convert::From<Builder> for crate::output::OperationOutput {
   27     44   
        fn from(builder: Builder) -> Self {
   28     45   
            builder.build()
   29     46   
        }
   30     47   
    }
   31         -
    /// A builder for [`OperationOutput`](crate::output::OperationOutput).
          48  +
    /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:130 */A builder for [`OperationOutput`](crate::output::OperationOutput).
          49  +
    /* RustType.kt:516 */
   32     50   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          51  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   33     52   
    pub struct Builder {
          53  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:225 */
   34     54   
        pub(crate) message: ::std::option::Option<::std::string::String>,
          55  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:137 */
   35     56   
    }
          57  +
    /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   36     58   
    impl Builder {
          59  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:241 */
   37     60   
        #[allow(missing_docs)] // documentation missing in model
          61  +
                               /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   38     62   
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
   39         -
            self.message = input;
          63  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */
          64  +
            self.message =
          65  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:247 */input
          66  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:245 */;
   40     67   
            self
          68  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:244 */
   41     69   
        }
   42         -
        /// Consumes the builder and constructs a [`OperationOutput`](crate::output::OperationOutput).
          70  +
        /// /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:150 */Consumes the builder and constructs a [`OperationOutput`](crate::output::OperationOutput).
          71  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:159 */
   43     72   
        pub fn build(self) -> crate::output::OperationOutput {
   44     73   
            self.build_enforcing_required_and_enum_traits()
   45     74   
        }
          75  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   46     76   
        fn build_enforcing_required_and_enum_traits(self) -> crate::output::OperationOutput {
          77  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   47     78   
            crate::output::OperationOutput {
          79  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:186 */
   48     80   
                message: self.message,
          81  +
                /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:182 */
   49     82   
            }
          83  +
            /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:171 */
   50     84   
        }
          85  +
        /* ServerBuilderGeneratorWithoutPublicConstrainedTypes.kt:141 */
   51     86   
    }
          87  +
          88  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   52     89   
}

tmp-codegen-diff/codegen-server-test-typescript/simple/rust-server-codegen-typescript/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-typescript/simple/rust-server-codegen-typescript/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-typescript/simple/rust-server-codegen-typescript/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))?
         136  +
                /* ServerHttpBoundProtocolGenerator.kt:476 */
         137  +
            } /* ServerHttpBoundProtocolGenerator.kt:468 */
   98    138   
        }
   99         -
        }
         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   
                )
         196  +
            } /* JsonParserGenerator.kt:685 */
  139    197   
        }
         198  +
        /* JsonParserGenerator.kt:684 */
  140    199   
    }
  141         -
    }
         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-typescript/simple/rust-server-codegen-typescript/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   
}