Server Test

Server Test

rev. dfb5149b65b7bcc09edd15b8e071ad43b5ac5943 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/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 +82,84 @@
   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");

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/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 = std::convert::Infallible;
   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/simple/rust-server-codegen/src/output.rs

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

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

@@ -1,1 +12,13 @@
    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  +
/* JsonParserGenerator.kt:227 */
    4      5   
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
    5      6   
    if data.is_empty() {
    6      7   
        b"{}"
    7      8   
    } else {
    8      9   
        data
    9     10   
    }
   10     11   
}
   11     12   
   12     13   
pub(crate) mod shape_operation_output;

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

@@ -1,1 +113,161 @@
    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::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  +
/* JsonParserGenerator.kt:148 */
   66     93   
pub(crate) fn de_operation(
   67     94   
    value: &[u8],
   68     95   
    mut builder: crate::input::operation_input::Builder,
   69     96   
) -> ::std::result::Result<
   70     97   
    crate::input::operation_input::Builder,
   71     98   
    ::aws_smithy_json::deserialize::error::DeserializeError,
   72     99   
> {
         100  +
    /* JsonParserGenerator.kt:153 */
   73    101   
    let mut tokens_owned =
   74    102   
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
   75    103   
            .peekable();
   76    104   
    let tokens = &mut tokens_owned;
   77    105   
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         106  +
    /* JsonParserGenerator.kt:684 */
   78    107   
    loop {
         108  +
        /* JsonParserGenerator.kt:685 */
   79    109   
        match tokens.next().transpose()? {
         110  +
            /* JsonParserGenerator.kt:686 */
   80    111   
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
   81    112   
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         113  +
                /* JsonParserGenerator.kt:260 */
   82    114   
                match key.to_unescaped()?.as_ref() {
         115  +
                    /* JsonParserGenerator.kt:262 */
   83    116   
                    "message" => {
         117  +
                        /* JsonParserGenerator.kt:272 */
   84    118   
                        builder = builder.set_message(
         119  +
                            /* JsonParserGenerator.kt:354 */
   85    120   
                            ::aws_smithy_json::deserialize::token::expect_string_or_null(
   86    121   
                                tokens.next(),
   87    122   
                            )?
   88         -
                            .map(|s| s.to_unescaped().map(|u| u.into_owned()))
   89         -
                            .transpose()?,
         123  +
                            .map(|s|
         124  +
                                /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
         125  +
                                    /* JsonParserGenerator.kt:348 */u.into_owned()
         126  +
                                /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
         127  +
                            .transpose()?, /* JsonParserGenerator.kt:272 */
   90    128   
                        );
         129  +
                        /* JsonParserGenerator.kt:262 */
   91    130   
                    }
   92         -
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         131  +
                    /* JsonParserGenerator.kt:290 */
         132  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
   93    133   
                }
         134  +
                /* JsonParserGenerator.kt:686 */
   94    135   
            }
         136  +
            /* JsonParserGenerator.kt:695 */
   95    137   
            other => {
   96    138   
                return Err(
   97    139   
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
   98    140   
                        "expected object key or end object, found: {:?}",
   99    141   
                        other
  100    142   
                    )),
  101    143   
                )
         144  +
            } /* JsonParserGenerator.kt:685 */
  102    145   
        }
         146  +
        /* JsonParserGenerator.kt:684 */
  103    147   
    }
  104         -
    }
         148  +
    /* JsonParserGenerator.kt:250 */
  105    149   
    if tokens.next().is_some() {
         150  +
        /* JsonParserGenerator.kt:251 */
  106    151   
        return Err(
  107    152   
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
  108    153   
                "found more JSON tokens after completing parsing",
  109    154   
            ),
  110    155   
        );
         156  +
        /* JsonParserGenerator.kt:250 */
  111    157   
    }
         158  +
    /* JsonParserGenerator.kt:163 */
  112    159   
    Ok(builder)
         160  +
    /* JsonParserGenerator.kt:148 */
  113    161   
}

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/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   
}

tmp-codegen-diff/codegen-server-test/simple/rust-server-codegen/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 [`SimpleService`].
    3      4   
///
    4      5   
/// Constructed via [`SimpleService::builder`].
    5      6   
pub struct SimpleServiceBuilder<Body, L, HttpPl, ModelPl> {
    6      7   
    operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7      8   
    layer: L,
    8      9   
    http_plugin: HttpPl,
    9     10   
    model_plugin: ModelPl,
   10     11   
}
   11     12   
@@ -475,476 +534,536 @@
  495    496   
            "com.amazonaws.simple",
  496    497   
            "SimpleService",
  497    498   
        );
  498    499   
  499    500   
    const VERSION: Option<&'static str> = Some("");
  500    501   
  501    502   
    type Protocol = ::aws_smithy_http_server::protocol::rest_json_1::RestJson1;
  502    503   
  503    504   
    type Operations = Operation;
  504    505   
}
         506  +
/* ServiceConfigGenerator.kt:178 */
  505    507   
/// Configuration for the [`SimpleService`]. This is the central place where to register and
  506    508   
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
  507    509   
///
  508    510   
/// ```rust,no_run
  509    511   
/// # use simple::SimpleServiceConfig;
  510    512   
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
  511    513   
/// # use ::tower::layer::util::Identity;
  512    514   
/// # let authentication_plugin = IdentityPlugin;
  513    515   
/// # let authorization_plugin = IdentityPlugin;
  514    516   
/// # let server_request_id_provider_layer = Identity::new();
@@ -590,592 +649,652 @@
  610    612   
  611    613   
    /// Build the configuration.
  612    614   
    pub fn build(self) -> super::SimpleServiceConfig<L, H, M> {
  613    615   
        super::SimpleServiceConfig {
  614    616   
            layers: self.layers,
  615    617   
            http_plugins: self.http_plugins,
  616    618   
            model_plugins: self.model_plugins,
  617    619   
        }
  618    620   
    }
  619    621   
}
         622  +
/* ScopeMacroGenerator.kt:81 */
  620    623   
/// A macro to help with scoping [plugins](crate::server::plugin) to a subset of all operations.
  621    624   
///
  622    625   
/// In contrast to [`crate::server::scope`](crate::server::scope), this macro has knowledge
  623    626   
/// of the service and any operations _not_ specified will be placed in the opposing group.
  624    627   
///
  625    628   
/// # Example
  626    629   
///
  627    630   
/// ```rust
  628    631   
/// scope! {
  629    632   
///     /// Includes [`Operation`], excluding all other operations.

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

@@ -1,1 +149,269 @@
    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 `MalformedUniqueItems` operation.
           4  +
/* ServerOperationErrorGenerator.kt:64 */
    3      5   
/// Each variant represents an error that can occur for the `MalformedUniqueItems` operation.
           6  +
/* RustType.kt:516 */
    4      7   
#[derive(::std::fmt::Debug)]
    5         -
pub enum MalformedUniqueItemsError {
    6         -
    /// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
           8  +
pub /* ServerOperationErrorGenerator.kt:66 */ enum MalformedUniqueItemsError {
           9  +
    /// /* ServerOperationErrorGenerator.kt:68 */A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
          10  +
    /* ServerOperationErrorGenerator.kt:71 */
    7     11   
    ValidationException(crate::error::ValidationException),
          12  +
    /* ServerOperationErrorGenerator.kt:66 */
    8     13   
}
          14  +
/* ServerOperationErrorGenerator.kt:75 */
    9     15   
impl ::std::fmt::Display for MalformedUniqueItemsError {
          16  +
    /* ServerOperationErrorGenerator.kt:76 */
   10     17   
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          18  +
        /* ServerOperationErrorGenerator.kt:139 */
   11     19   
        match &self {
   12         -
            MalformedUniqueItemsError::ValidationException(_inner) => _inner.fmt(f),
          20  +
            /* ServerOperationErrorGenerator.kt:142 */
          21  +
            MalformedUniqueItemsError::ValidationException(_inner) =>
          22  +
            /* ServerOperationErrorGenerator.kt:78 */
          23  +
            {
          24  +
                _inner.fmt(f)
          25  +
            }
          26  +
            /* ServerOperationErrorGenerator.kt:139 */
   13     27   
        }
          28  +
        /* ServerOperationErrorGenerator.kt:76 */
   14     29   
    }
          30  +
    /* ServerOperationErrorGenerator.kt:75 */
   15     31   
}
          32  +
/* ServerOperationErrorGenerator.kt:83 */
   16     33   
impl MalformedUniqueItemsError {
          34  +
    /* ServerOperationErrorGenerator.kt:87 */
   17     35   
    /// Returns `true` if the error kind is `MalformedUniqueItemsError::ValidationException`.
          36  +
    /* ServerOperationErrorGenerator.kt:88 */
   18     37   
    pub fn is_validation_exception(&self) -> bool {
          38  +
        /* ServerOperationErrorGenerator.kt:89 */
   19     39   
        matches!(&self, MalformedUniqueItemsError::ValidationException(_))
          40  +
        /* ServerOperationErrorGenerator.kt:88 */
   20     41   
    }
          42  +
    /* ServerOperationErrorGenerator.kt:92 */
   21     43   
    /// Returns the error name string by matching the correct variant.
          44  +
    /* ServerOperationErrorGenerator.kt:93 */
   22     45   
    pub fn name(&self) -> &'static str {
          46  +
        /* ServerOperationErrorGenerator.kt:139 */
   23     47   
        match &self {
   24         -
            MalformedUniqueItemsError::ValidationException(_inner) => _inner.name(),
          48  +
            /* ServerOperationErrorGenerator.kt:142 */
          49  +
            MalformedUniqueItemsError::ValidationException(_inner) =>
          50  +
            /* ServerOperationErrorGenerator.kt:95 */
          51  +
            {
          52  +
                _inner.name()
   25     53   
            }
          54  +
            /* ServerOperationErrorGenerator.kt:139 */
   26     55   
        }
          56  +
        /* ServerOperationErrorGenerator.kt:93 */
          57  +
    }
          58  +
    /* ServerOperationErrorGenerator.kt:83 */
   27     59   
}
          60  +
/* ServerOperationErrorGenerator.kt:100 */
   28     61   
impl ::std::error::Error for MalformedUniqueItemsError {
          62  +
    /* ServerOperationErrorGenerator.kt:101 */
   29     63   
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
          64  +
        /* ServerOperationErrorGenerator.kt:139 */
   30     65   
        match &self {
   31         -
            MalformedUniqueItemsError::ValidationException(_inner) => Some(_inner),
          66  +
            /* ServerOperationErrorGenerator.kt:142 */
          67  +
            MalformedUniqueItemsError::ValidationException(_inner) =>
          68  +
            /* ServerOperationErrorGenerator.kt:103 */
          69  +
            {
          70  +
                Some(_inner)
   32     71   
            }
          72  +
            /* ServerOperationErrorGenerator.kt:139 */
   33     73   
        }
          74  +
        /* ServerOperationErrorGenerator.kt:101 */
          75  +
    }
          76  +
    /* ServerOperationErrorGenerator.kt:100 */
   34     77   
}
          78  +
/* ServerOperationErrorGenerator.kt:110 */
   35     79   
impl ::std::convert::From<crate::error::ValidationException>
   36     80   
    for crate::error::MalformedUniqueItemsError
   37     81   
{
          82  +
    /* ServerOperationErrorGenerator.kt:111 */
   38     83   
    fn from(variant: crate::error::ValidationException) -> crate::error::MalformedUniqueItemsError {
          84  +
        /* ServerOperationErrorGenerator.kt:112 */
   39     85   
        Self::ValidationException(variant)
          86  +
        /* ServerOperationErrorGenerator.kt:111 */
   40     87   
    }
          88  +
    /* ServerOperationErrorGenerator.kt:110 */
   41     89   
}
   42     90   
   43         -
/// A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
          91  +
/// /* StructureGenerator.kt:197 */A standard error for input validation failures. This should be thrown by services when a member of the input structure falls outside of the modeled or documented constraints.
          92  +
/* RustType.kt:516 */
   44     93   
#[derive(
   45     94   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   46     95   
)]
   47         -
pub struct ValidationException {
   48         -
    /// A summary of the validation failure.
          96  +
pub /* StructureGenerator.kt:201 */ struct ValidationException {
          97  +
    /// /* StructureGenerator.kt:231 */A summary of the validation failure.
   49     98   
    pub message: ::std::string::String,
   50         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
          99  +
    /// /* StructureGenerator.kt:231 */A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
   51    100   
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         101  +
    /* StructureGenerator.kt:201 */
   52    102   
}
         103  +
/* StructureGenerator.kt:135 */
   53    104   
impl ValidationException {
   54         -
    /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         105  +
    /// /* StructureGenerator.kt:231 */A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         106  +
    /* StructureGenerator.kt:166 */
   55    107   
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
         108  +
        /* StructureGenerator.kt:169 */
   56    109   
        self.field_list.as_deref()
         110  +
        /* StructureGenerator.kt:166 */
   57    111   
    }
         112  +
    /* StructureGenerator.kt:135 */
   58    113   
}
         114  +
/* ErrorImplGenerator.kt:99 */
   59    115   
impl ValidationException {
         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   
        "ValidationException"
   68    126   
    }
         127  +
    /* ErrorImplGenerator.kt:99 */
   69    128   
}
         129  +
/* ErrorImplGenerator.kt:153 */
   70    130   
impl ::std::fmt::Display for ValidationException {
         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, "ValidationException")?;
         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 ValidationException {}
         149  +
/* ServerCodegenVisitor.kt:345 */
   80    150   
impl ValidationException {
   81         -
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
         151  +
    /// /* ServerBuilderGenerator.kt:294 */Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
         152  +
    /* ServerBuilderGenerator.kt:295 */
   82    153   
    pub fn builder() -> crate::error::validation_exception::Builder {
         154  +
        /* ServerBuilderGenerator.kt:296 */
   83    155   
        crate::error::validation_exception::Builder::default()
         156  +
        /* ServerBuilderGenerator.kt:295 */
   84    157   
    }
         158  +
    /* ServerCodegenVisitor.kt:345 */
   85    159   
}
   86         -
/// See [`ValidationException`](crate::error::ValidationException).
         160  +
/// /* ServerBuilderGenerator.kt:171 */See [`ValidationException`](crate::error::ValidationException).
   87    161   
pub mod validation_exception {
   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.
         165  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
         166  +
    /* RustType.kt:516 */
   91    167   
    #[non_exhaustive]
         168  +
    /* ServerBuilderConstraintViolations.kt:75 */
   92    169   
    #[allow(clippy::enum_variant_names)]
   93    170   
    pub enum ConstraintViolation {
   94         -
        /// `message` was not provided but it is required when building `ValidationException`.
         171  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`message` was not provided but it is required when building `ValidationException`.
         172  +
        /* ServerBuilderConstraintViolations.kt:143 */
   95    173   
        MissingMessage,
         174  +
        /* ServerBuilderConstraintViolations.kt:75 */
   96    175   
    }
         176  +
    /* ServerBuilderConstraintViolations.kt:117 */
   97    177   
    impl ::std::fmt::Display for ConstraintViolation {
         178  +
        /* ServerBuilderConstraintViolations.kt:118 */
   98    179   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         180  +
            /* ServerBuilderConstraintViolations.kt:119 */
   99    181   
            match self {
  100         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
  101         -
            }
         182  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
         183  +
            /* ServerBuilderConstraintViolations.kt:119 */}
         184  +
            /* ServerBuilderConstraintViolations.kt:118 */
  102    185   
        }
         186  +
        /* ServerBuilderConstraintViolations.kt:117 */
  103    187   
    }
         188  +
    /* ServerBuilderConstraintViolations.kt:84 */
  104    189   
    impl ::std::error::Error for ConstraintViolation {}
         190  +
    /* ServerBuilderGenerator.kt:446 */
  105    191   
    impl ::std::convert::TryFrom<Builder> for crate::error::ValidationException {
  106    192   
        type Error = ConstraintViolation;
  107    193   
  108    194   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  109    195   
            builder.build()
  110    196   
        }
  111    197   
    }
  112         -
    /// A builder for [`ValidationException`](crate::error::ValidationException).
         198  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`ValidationException`](crate::error::ValidationException).
         199  +
    /* RustType.kt:516 */
  113    200   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         201  +
    /* ServerBuilderGenerator.kt:211 */
  114    202   
    pub struct Builder {
         203  +
        /* ServerBuilderGenerator.kt:308 */
  115    204   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         205  +
        /* ServerBuilderGenerator.kt:308 */
  116    206   
        pub(crate) field_list:
  117    207   
            ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         208  +
        /* ServerBuilderGenerator.kt:211 */
  118    209   
    }
         210  +
    /* ServerBuilderGenerator.kt:215 */
  119    211   
    impl Builder {
  120         -
        /// A summary of the validation failure.
         212  +
        /// /* ServerBuilderGenerator.kt:331 */A summary of the validation failure.
         213  +
        /* ServerBuilderGenerator.kt:343 */
  121    214   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  122         -
            self.message = Some(input);
         215  +
            /* ServerBuilderGenerator.kt:344 */
         216  +
            self.message =
         217  +
                /* ServerBuilderGenerator.kt:345 */Some(
         218  +
                    /* ServerBuilderGenerator.kt:376 */input
         219  +
                /* ServerBuilderGenerator.kt:345 */)
         220  +
            /* ServerBuilderGenerator.kt:344 */;
  123    221   
            self
         222  +
            /* ServerBuilderGenerator.kt:343 */
  124    223   
        }
  125         -
        /// A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         224  +
        /// /* ServerBuilderGenerator.kt:331 */A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
         225  +
        /* ServerBuilderGenerator.kt:343 */
  126    226   
        pub fn field_list(
  127    227   
            mut self,
  128    228   
            input: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
  129    229   
        ) -> Self {
  130         -
            self.field_list = input;
         230  +
            /* ServerBuilderGenerator.kt:344 */
         231  +
            self.field_list =
         232  +
                /* ServerBuilderGenerator.kt:376 */input
         233  +
            /* ServerBuilderGenerator.kt:344 */;
  131    234   
            self
         235  +
            /* ServerBuilderGenerator.kt:343 */
  132    236   
        }
  133         -
        /// Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
  134         -
        ///
         237  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
         238  +
        /// /* ServerBuilderGenerator.kt:260 */
  135    239   
        /// The builder fails to construct a [`ValidationException`](crate::error::ValidationException) if a [`ConstraintViolation`] occurs.
  136    240   
        ///
         241  +
        /* ServerBuilderGenerator.kt:271 */
  137    242   
        pub fn build(self) -> Result<crate::error::ValidationException, ConstraintViolation> {
  138    243   
            self.build_enforcing_all_constraints()
  139    244   
        }
         245  +
        /* ServerBuilderGenerator.kt:283 */
  140    246   
        fn build_enforcing_all_constraints(
  141    247   
            self,
  142    248   
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
  143         -
            Ok(crate::error::ValidationException {
  144         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         249  +
            /* ServerBuilderGenerator.kt:287 */
         250  +
            Ok(
         251  +
                /* ServerBuilderGenerator.kt:542 */
         252  +
                crate::error::ValidationException {
         253  +
                    /* ServerBuilderGenerator.kt:546 */
         254  +
                    message: self
         255  +
                        .message
         256  +
                        /* ServerBuilderGenerator.kt:569 */
         257  +
                        .ok_or(ConstraintViolation::MissingMessage)?,
         258  +
                    /* ServerBuilderGenerator.kt:546 */
  145    259   
                    field_list: self.field_list,
  146         -
            })
         260  +
                    /* ServerBuilderGenerator.kt:542 */
         261  +
                }, /* ServerBuilderGenerator.kt:287 */
         262  +
            )
         263  +
            /* ServerBuilderGenerator.kt:283 */
  147    264   
        }
         265  +
        /* ServerBuilderGenerator.kt:215 */
  148    266   
    }
         267  +
         268  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  149    269   
}

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

@@ -1,1 +184,260 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* StructureGenerator.kt:197 */
    2      3   
#[allow(missing_docs)] // documentation missing in model
           4  +
/* RustType.kt:516 */
    3      5   
#[derive(
    4      6   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    5      7   
)]
    6         -
pub struct MalformedUniqueItemsInput {
           8  +
pub /* StructureGenerator.kt:201 */ struct MalformedUniqueItemsInput {
           9  +
    /* StructureGenerator.kt:231 */
    7     10   
    #[allow(missing_docs)] // documentation missing in model
    8     11   
    pub set: ::std::option::Option<crate::model::SimpleSet>,
          12  +
    /* StructureGenerator.kt:231 */
    9     13   
    #[allow(missing_docs)] // documentation missing in model
   10     14   
    pub complex_set: ::std::option::Option<crate::model::ComplexSet>,
          15  +
    /* StructureGenerator.kt:201 */
   11     16   
}
          17  +
/* StructureGenerator.kt:135 */
   12     18   
impl MalformedUniqueItemsInput {
          19  +
    /* StructureGenerator.kt:231 */
   13     20   
    #[allow(missing_docs)] // documentation missing in model
          21  +
                           /* StructureGenerator.kt:166 */
   14     22   
    pub fn set(&self) -> ::std::option::Option<&crate::model::SimpleSet> {
          23  +
        /* StructureGenerator.kt:170 */
   15     24   
        self.set.as_ref()
          25  +
        /* StructureGenerator.kt:166 */
   16     26   
    }
          27  +
    /* StructureGenerator.kt:231 */
   17     28   
    #[allow(missing_docs)] // documentation missing in model
          29  +
                           /* StructureGenerator.kt:166 */
   18     30   
    pub fn complex_set(&self) -> ::std::option::Option<&crate::model::ComplexSet> {
          31  +
        /* StructureGenerator.kt:170 */
   19     32   
        self.complex_set.as_ref()
          33  +
        /* StructureGenerator.kt:166 */
   20     34   
    }
          35  +
    /* StructureGenerator.kt:135 */
   21     36   
}
          37  +
/* ServerCodegenVisitor.kt:345 */
   22     38   
impl MalformedUniqueItemsInput {
   23         -
    /// Creates a new builder-style object to manufacture [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
          39  +
    /// /* ServerBuilderGenerator.kt:294 */Creates a new builder-style object to manufacture [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
          40  +
    /* ServerBuilderGenerator.kt:295 */
   24     41   
    pub fn builder() -> crate::input::malformed_unique_items_input::Builder {
          42  +
        /* ServerBuilderGenerator.kt:296 */
   25     43   
        crate::input::malformed_unique_items_input::Builder::default()
          44  +
        /* ServerBuilderGenerator.kt:295 */
   26     45   
    }
          46  +
    /* ServerCodegenVisitor.kt:345 */
   27     47   
}
          48  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
   28     49   
impl crate::constrained::Constrained for crate::input::MalformedUniqueItemsInput {
   29     50   
    type Unconstrained = crate::input::malformed_unique_items_input::Builder;
   30     51   
}
   31         -
/// See [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
          52  +
/// /* ServerBuilderGenerator.kt:171 */See [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
   32     53   
pub mod malformed_unique_items_input {
   33     54   
          55  +
    /* RustType.kt:516 */
   34     56   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
   35         -
    /// Holds one variant for each of the ways the builder can fail.
          57  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
          58  +
    /* RustType.kt:516 */
   36     59   
    #[non_exhaustive]
          60  +
    /* ServerBuilderConstraintViolations.kt:75 */
   37     61   
    #[allow(clippy::enum_variant_names)]
   38     62   
    pub enum ConstraintViolation {
   39         -
        /// Constraint violation occurred building member `set` when building `MalformedUniqueItemsInput`.
          63  +
        /// /* ServerBuilderConstraintViolations.kt:158 */Constraint violation occurred building member `set` when building `MalformedUniqueItemsInput`.
          64  +
        /* RustType.kt:516 */
   40     65   
        #[doc(hidden)]
          66  +
        /* ServerBuilderConstraintViolations.kt:164 */
   41     67   
        Set(crate::model::simple_set::ConstraintViolation),
   42         -
        /// Constraint violation occurred building member `complex_set` when building `MalformedUniqueItemsInput`.
          68  +
        /// /* ServerBuilderConstraintViolations.kt:158 */Constraint violation occurred building member `complex_set` when building `MalformedUniqueItemsInput`.
          69  +
        /* RustType.kt:516 */
   43     70   
        #[doc(hidden)]
          71  +
        /* ServerBuilderConstraintViolations.kt:164 */
   44     72   
        ComplexSet(crate::model::complex_set::ConstraintViolation),
          73  +
        /* ServerBuilderConstraintViolations.kt:75 */
   45     74   
    }
          75  +
    /* ServerBuilderConstraintViolations.kt:117 */
   46     76   
    impl ::std::fmt::Display for ConstraintViolation {
          77  +
        /* ServerBuilderConstraintViolations.kt:118 */
   47     78   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          79  +
            /* ServerBuilderConstraintViolations.kt:119 */
   48     80   
            match self {
   49         -
                ConstraintViolation::Set(_) => write!(f, "constraint violation occurred building member `set` when building `MalformedUniqueItemsInput`"),
   50         -
                ConstraintViolation::ComplexSet(_) => write!(f, "constraint violation occurred building member `complex_set` when building `MalformedUniqueItemsInput`"),
   51         -
            }
          81  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::Set(_) => write!(f, "constraint violation occurred building member `set` when building `MalformedUniqueItemsInput`"),
          82  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::ComplexSet(_) => write!(f, "constraint violation occurred building member `complex_set` when building `MalformedUniqueItemsInput`"),
          83  +
            /* ServerBuilderConstraintViolations.kt:119 */}
          84  +
            /* ServerBuilderConstraintViolations.kt:118 */
   52     85   
        }
          86  +
        /* ServerBuilderConstraintViolations.kt:117 */
   53     87   
    }
          88  +
    /* ServerBuilderConstraintViolations.kt:84 */
   54     89   
    impl ::std::error::Error for ConstraintViolation {}
          90  +
    /* ServerBuilderConstraintViolations.kt:171 */
   55     91   
    impl ConstraintViolation {
   56     92   
        pub(crate) fn as_validation_exception_field(
   57     93   
            self,
   58     94   
            path: ::std::string::String,
   59     95   
        ) -> crate::model::ValidationExceptionField {
   60     96   
            match self {
   61     97   
                ConstraintViolation::Set(inner) => {
   62     98   
                    inner.as_validation_exception_field(path + "/set")
   63     99   
                }
   64    100   
                ConstraintViolation::ComplexSet(inner) => {
   65    101   
                    inner.as_validation_exception_field(path + "/complexSet")
   66    102   
                }
   67    103   
            }
   68    104   
        }
   69    105   
    }
         106  +
    /* ServerBuilderGenerator.kt:234 */
   70    107   
    impl ::std::convert::From<ConstraintViolation>
   71    108   
        for ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection
   72    109   
    {
   73    110   
        fn from(constraint_violation: ConstraintViolation) -> Self {
   74    111   
            let first_validation_exception_field =
   75    112   
                constraint_violation.as_validation_exception_field("".to_owned());
   76    113   
            let validation_exception = crate::error::ValidationException {
   77    114   
                message: format!(
   78    115   
                    "1 validation error detected. {}",
   79    116   
                    &first_validation_exception_field.message
   80    117   
                ),
   81    118   
                field_list: Some(vec![first_validation_exception_field]),
   82    119   
            };
   83    120   
            Self::ConstraintViolation(
   84    121   
                                crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(&validation_exception)
   85    122   
                                    .expect("validation exceptions should never fail to serialize; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues")
   86    123   
                            )
   87    124   
        }
   88    125   
    }
         126  +
    /* ServerBuilderGenerator.kt:244 */
   89    127   
    impl ::std::convert::From<Builder>
   90    128   
        for crate::constrained::MaybeConstrained<crate::input::MalformedUniqueItemsInput>
   91    129   
    {
   92    130   
        fn from(builder: Builder) -> Self {
   93    131   
            Self::Unconstrained(builder)
   94    132   
        }
   95    133   
    }
         134  +
    /* ServerBuilderGenerator.kt:446 */
   96    135   
    impl ::std::convert::TryFrom<Builder> for crate::input::MalformedUniqueItemsInput {
   97    136   
        type Error = ConstraintViolation;
   98    137   
   99    138   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  100    139   
            builder.build()
  101    140   
        }
  102    141   
    }
  103         -
    /// A builder for [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
         142  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
         143  +
    /* RustType.kt:516 */
  104    144   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         145  +
    /* ServerBuilderGenerator.kt:211 */
  105    146   
    pub struct Builder {
         147  +
        /* ServerBuilderGenerator.kt:308 */
  106    148   
        pub(crate) set:
  107    149   
            ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::SimpleSet>>,
         150  +
        /* ServerBuilderGenerator.kt:308 */
  108    151   
        pub(crate) complex_set:
  109    152   
            ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::ComplexSet>>,
         153  +
        /* ServerBuilderGenerator.kt:211 */
  110    154   
    }
         155  +
    /* ServerBuilderGenerator.kt:215 */
  111    156   
    impl Builder {
         157  +
        /* ServerBuilderGenerator.kt:331 */
  112    158   
        #[allow(missing_docs)] // documentation missing in model
         159  +
                               /* ServerBuilderGenerator.kt:343 */
  113    160   
        pub fn set(mut self, input: ::std::option::Option<crate::model::SimpleSet>) -> Self {
  114         -
            self.set = input.map(
  115         -
                #[allow(clippy::redundant_closure)]
  116         -
                |v| crate::constrained::MaybeConstrained::Constrained(v),
  117         -
            );
         161  +
            /* ServerBuilderGenerator.kt:344 */
         162  +
            self.set =
         163  +
                /* ServerBuilderGenerator.kt:367 */input.map(crate::constrained::MaybeConstrained::Constrained)
         164  +
            /* ServerBuilderGenerator.kt:344 */;
  118    165   
            self
         166  +
            /* ServerBuilderGenerator.kt:343 */
  119    167   
        }
         168  +
        /* ServerBuilderGenerator.kt:426 */
  120    169   
        #[allow(missing_docs)] // documentation missing in model
         170  +
                               /* ServerBuilderGenerator.kt:428 */
  121    171   
        pub(crate) fn set_set(
  122    172   
            mut self,
  123    173   
            input: Option<
  124    174   
                impl ::std::convert::Into<crate::constrained::MaybeConstrained<crate::model::SimpleSet>>,
  125    175   
            >,
  126    176   
        ) -> Self {
         177  +
            /* ServerBuilderGenerator.kt:429 */
  127    178   
            self.set = input.map(|v| v.into());
  128    179   
            self
         180  +
            /* ServerBuilderGenerator.kt:428 */
  129    181   
        }
         182  +
        /* ServerBuilderGenerator.kt:331 */
  130    183   
        #[allow(missing_docs)] // documentation missing in model
         184  +
                               /* ServerBuilderGenerator.kt:343 */
  131    185   
        pub fn complex_set(
  132    186   
            mut self,
  133    187   
            input: ::std::option::Option<crate::model::ComplexSet>,
  134    188   
        ) -> Self {
  135         -
            self.complex_set = input.map(
  136         -
                #[allow(clippy::redundant_closure)]
  137         -
                |v| crate::constrained::MaybeConstrained::Constrained(v),
  138         -
            );
         189  +
            /* ServerBuilderGenerator.kt:344 */
         190  +
            self.complex_set =
         191  +
                /* ServerBuilderGenerator.kt:367 */input.map(crate::constrained::MaybeConstrained::Constrained)
         192  +
            /* ServerBuilderGenerator.kt:344 */;
  139    193   
            self
         194  +
            /* ServerBuilderGenerator.kt:343 */
  140    195   
        }
         196  +
        /* ServerBuilderGenerator.kt:426 */
  141    197   
        #[allow(missing_docs)] // documentation missing in model
         198  +
                               /* ServerBuilderGenerator.kt:428 */
  142    199   
        pub(crate) fn set_complex_set(
  143    200   
            mut self,
  144    201   
            input: Option<
  145    202   
                impl ::std::convert::Into<
  146    203   
                    crate::constrained::MaybeConstrained<crate::model::ComplexSet>,
  147    204   
                >,
  148    205   
            >,
  149    206   
        ) -> Self {
         207  +
            /* ServerBuilderGenerator.kt:429 */
  150    208   
            self.complex_set = input.map(|v| v.into());
  151    209   
            self
         210  +
            /* ServerBuilderGenerator.kt:428 */
  152    211   
        }
  153         -
        /// Consumes the builder and constructs a [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
  154         -
        ///
         212  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
         213  +
        /// /* ServerBuilderGenerator.kt:260 */
  155    214   
        /// The builder fails to construct a [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) if a [`ConstraintViolation`] occurs.
  156    215   
        ///
  157         -
        /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         216  +
        /// /* ServerBuilderGenerator.kt:268 */If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         217  +
        /* ServerBuilderGenerator.kt:271 */
  158    218   
        pub fn build(self) -> Result<crate::input::MalformedUniqueItemsInput, ConstraintViolation> {
  159    219   
            self.build_enforcing_all_constraints()
  160    220   
        }
         221  +
        /* ServerBuilderGenerator.kt:283 */
  161    222   
        fn build_enforcing_all_constraints(
  162    223   
            self,
  163    224   
        ) -> Result<crate::input::MalformedUniqueItemsInput, ConstraintViolation> {
  164         -
            Ok(crate::input::MalformedUniqueItemsInput {
         225  +
            /* ServerBuilderGenerator.kt:287 */
         226  +
            Ok(
         227  +
                /* ServerBuilderGenerator.kt:542 */
         228  +
                crate::input::MalformedUniqueItemsInput {
         229  +
                    /* ServerBuilderGenerator.kt:546 */
  165    230   
                    set: self
  166    231   
                        .set
         232  +
                        /* ServerBuilderGenerator.kt:602 */
  167    233   
                        .map(|v| match v {
  168    234   
                            crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
  169    235   
                            crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
  170    236   
                        })
         237  +
                        /* ServerBuilderGenerator.kt:614 */
  171    238   
                        .map(|res| res.map_err(ConstraintViolation::Set))
  172    239   
                        .transpose()?,
         240  +
                    /* ServerBuilderGenerator.kt:546 */
  173    241   
                    complex_set: self
  174    242   
                        .complex_set
         243  +
                        /* ServerBuilderGenerator.kt:602 */
  175    244   
                        .map(|v| match v {
  176    245   
                            crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
  177    246   
                            crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
  178    247   
                        })
         248  +
                        /* ServerBuilderGenerator.kt:614 */
  179    249   
                        .map(|res| res.map_err(ConstraintViolation::ComplexSet))
  180    250   
                        .transpose()?,
  181         -
            })
         251  +
                    /* ServerBuilderGenerator.kt:542 */
         252  +
                }, /* ServerBuilderGenerator.kt:287 */
         253  +
            )
         254  +
            /* ServerBuilderGenerator.kt:283 */
  182    255   
        }
         256  +
        /* ServerBuilderGenerator.kt:215 */
  183    257   
    }
         258  +
         259  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  184    260   
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/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   
//! unique_items
   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 UniqueItemsService Smithy service.
   24     25   
//!
   25     26   
//! # Using UniqueItemsService
   26     27   
//!
   27     28   
//! The primary entrypoint is [`UniqueItemsService`]: 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 [`UniqueItemsService::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 +246,255 @@
  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, UniqueItemsService, UniqueItemsServiceBuilder,
  199    201   
    UniqueItemsServiceConfig, UniqueItemsServiceConfigBuilder,
  200    202   
};
  201    203   
  202         -
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         204  +
/// /* ServerRustModule.kt:55 */Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  203    205   
pub mod server {
  204    206   
    // Re-export all types from the `aws-smithy-http-server` crate.
  205    207   
    pub use ::aws_smithy_http_server::*;
         208  +
         209  +
    /* CodegenDelegator.kt:200 */
  206    210   
}
  207    211   
         212  +
/* CrateVersionCustomization.kt:23 */
  208    213   
/// Crate version number.
  209    214   
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
  210    215   
  211         -
/// All error types that operations can return. Documentation on these types is copied from the model.
         216  +
/// /* ServerRustModule.kt:55 */All error types that operations can return. Documentation on these types is copied from the model.
  212    217   
pub mod error;
  213    218   
  214         -
/// Input structures for operations. Documentation on these types is copied from the model.
         219  +
/// /* ServerRustModule.kt:55 */Input structures for operations. Documentation on these types is copied from the model.
  215    220   
pub mod input;
  216    221   
  217         -
/// Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
         222  +
/// /* ServerRustModule.kt:55 */Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
  218    223   
pub mod model;
  219    224   
  220         -
/// All operations that this crate can perform.
         225  +
/// /* ServerRustModule.kt:55 */All operations that this crate can perform.
  221    226   
pub mod operation;
  222    227   
         228  +
/* ServerRustModule.kt:79 */
  223    229   
/// A collection of types representing each operation defined in the service closure.
  224    230   
///
  225    231   
/// The [plugin system](::aws_smithy_http_server::plugin) makes use of these
  226    232   
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
  227    233   
/// parameterize [`Plugin`](::aws_smithy_http_server::plugin::Plugin) implementations. Their traits, such as
  228    234   
/// [`OperationShape`](::aws_smithy_http_server::operation::OperationShape), can be used to provide
  229    235   
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
  230    236   
pub mod operation_shape;
  231    237   
  232         -
/// Output structures for operations. Documentation on these types is copied from the model.
         238  +
/// /* ServerRustModule.kt:55 */Output structures for operations. Documentation on these types is copied from the model.
  233    239   
pub mod output;
  234    240   
         241  +
/* RustModule.kt:172 */
  235    242   
mod service;
  236    243   
  237         -
/// Data primitives referenced by other data types.
         244  +
/// /* ServerRustModule.kt:55 */Data primitives referenced by other data types.
  238    245   
pub mod types;
  239    246   
  240         -
/// Unconstrained types for constrained shapes.
         247  +
/// /* ServerRustModule.kt:55 */Unconstrained types for constrained shapes.
         248  +
/* RustModule.kt:172 */
  241    249   
mod unconstrained;
  242    250   
  243         -
/// Constrained types for constrained shapes.
         251  +
/// /* ServerRustModule.kt:55 */Constrained types for constrained shapes.
         252  +
/* RustModule.kt:172 */
  244    253   
mod constrained;
  245    254   
  246    255   
pub(crate) mod protocol_serde;

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/src/model.rs

@@ -1,1 +419,571 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
    3         -
/// Describes one specific validation failure for an input member.
           2  +
/* StructureGenerator.kt:197 */
           3  +
/// /* StructureGenerator.kt:197 */Describes one specific validation failure for an input member.
           4  +
/* RustType.kt:516 */
    4      5   
#[derive(
    5      6   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    6      7   
)]
    7         -
pub struct ValidationExceptionField {
    8         -
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
           8  +
pub /* StructureGenerator.kt:201 */ struct ValidationExceptionField {
           9  +
    /// /* StructureGenerator.kt:231 */A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
    9     10   
    pub path: ::std::string::String,
   10         -
    /// A detailed description of the validation failure.
          11  +
    /// /* StructureGenerator.kt:231 */A detailed description of the validation failure.
   11     12   
    pub message: ::std::string::String,
          13  +
    /* StructureGenerator.kt:201 */
   12     14   
}
          15  +
/* StructureGenerator.kt:135 */
   13     16   
impl ValidationExceptionField {
   14         -
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
          17  +
    /// /* StructureGenerator.kt:231 */A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
          18  +
    /* StructureGenerator.kt:166 */
   15     19   
    pub fn path(&self) -> &str {
          20  +
        /* StructureGenerator.kt:171 */
   16     21   
        use std::ops::Deref;
   17     22   
        self.path.deref()
          23  +
        /* StructureGenerator.kt:166 */
   18     24   
    }
   19         -
    /// A detailed description of the validation failure.
          25  +
    /// /* StructureGenerator.kt:231 */A detailed description of the validation failure.
          26  +
    /* StructureGenerator.kt:166 */
   20     27   
    pub fn message(&self) -> &str {
          28  +
        /* StructureGenerator.kt:171 */
   21     29   
        use std::ops::Deref;
   22     30   
        self.message.deref()
          31  +
        /* StructureGenerator.kt:166 */
   23     32   
    }
          33  +
    /* StructureGenerator.kt:135 */
   24     34   
}
          35  +
/* ServerCodegenVisitor.kt:345 */
   25     36   
impl ValidationExceptionField {
   26         -
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
          37  +
    /// /* ServerBuilderGenerator.kt:294 */Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
          38  +
    /* ServerBuilderGenerator.kt:295 */
   27     39   
    pub fn builder() -> crate::model::validation_exception_field::Builder {
          40  +
        /* ServerBuilderGenerator.kt:296 */
   28     41   
        crate::model::validation_exception_field::Builder::default()
          42  +
        /* ServerBuilderGenerator.kt:295 */
   29     43   
    }
          44  +
    /* ServerCodegenVisitor.kt:345 */
   30     45   
}
   31     46   
          47  +
/* ConstrainedCollectionGenerator.kt:93 */
   32     48   
#[allow(missing_docs)] // documentation missing in model
   33         -
///
          49  +
/// /* ConstrainedCollectionGenerator.kt:94 */
   34     50   
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
   35     51   
/// [constraint traits]. Use [`ComplexSet::try_from`] to construct values of this type.
   36     52   
///
   37     53   
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
   38     54   
///
          55  +
/* RustType.kt:516 */
   39     56   
#[derive(
   40     57   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
   41     58   
)]
   42         -
pub struct ComplexSet(pub(crate) ::std::vec::Vec<crate::model::ComplexSetStruct>);
          59  +
pub /* ConstrainedCollectionGenerator.kt:97 */ struct ComplexSet(
          60  +
    pub(crate) ::std::vec::Vec<crate::model::ComplexSetStruct>,
          61  +
);
          62  +
/* ConstrainedCollectionGenerator.kt:104 */
   43     63   
impl ComplexSet {
          64  +
    /* ConstrainedCollectionGenerator.kt:106 */
   44     65   
    /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::ComplexSetStruct>`].
   45     66   
    pub fn inner(&self) -> &::std::vec::Vec<crate::model::ComplexSetStruct> {
   46     67   
        &self.0
   47     68   
    }
          69  +
    /* ConstrainedCollectionGenerator.kt:116 */
   48     70   
    /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::ComplexSetStruct>`].
   49     71   
    pub fn into_inner(self) -> ::std::vec::Vec<crate::model::ComplexSetStruct> {
   50     72   
        self.0
   51     73   
    }
   52     74   
   53     75   
    fn check_unique_items(
   54     76   
        items: ::std::vec::Vec<crate::model::ComplexSetStruct>,
   55     77   
    ) -> ::std::result::Result<
   56     78   
        ::std::vec::Vec<crate::model::ComplexSetStruct>,
   57     79   
        crate::model::complex_set::ConstraintViolation,
   58     80   
    > {
   59     81   
        let mut seen = ::std::collections::HashMap::new();
   60     82   
        let mut duplicate_indices = ::std::vec::Vec::new();
   61     83   
        for (idx, item) in items.iter().enumerate() {
   62     84   
            if let Some(prev_idx) = seen.insert(item, idx) {
   63     85   
                duplicate_indices.push(prev_idx);
   64     86   
            }
   65     87   
        }
   66     88   
   67     89   
        let mut last_duplicate_indices = ::std::vec::Vec::new();
   68     90   
        for idx in &duplicate_indices {
   69     91   
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
   70     92   
                last_duplicate_indices.push(prev_idx);
   71     93   
            }
   72     94   
        }
   73     95   
        duplicate_indices.extend(last_duplicate_indices);
   74     96   
   75     97   
        if !duplicate_indices.is_empty() {
   76     98   
            debug_assert!(duplicate_indices.len() >= 2);
   77     99   
            Err(
   78    100   
                crate::model::complex_set::ConstraintViolation::UniqueItems {
   79    101   
                    duplicate_indices,
   80    102   
                    original: items,
   81    103   
                },
   82    104   
            )
   83    105   
        } else {
   84    106   
            Ok(items)
   85    107   
        }
   86    108   
    }
         109  +
    /* ConstrainedCollectionGenerator.kt:104 */
   87    110   
}
         111  +
/* ConstrainedCollectionGenerator.kt:133 */
   88    112   
impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::ComplexSetStruct>> for ComplexSet {
   89    113   
    type Error = crate::model::complex_set::ConstraintViolation;
   90    114   
   91    115   
    /// Constructs a `ComplexSet` from an [`::std::vec::Vec<crate::model::ComplexSetStruct>`], failing when the provided value does not satisfy the modeled constraints.
   92    116   
    fn try_from(
   93    117   
        value: ::std::vec::Vec<crate::model::ComplexSetStruct>,
   94    118   
    ) -> ::std::result::Result<Self, Self::Error> {
   95    119   
        let value = Self::check_unique_items(value)?;
   96    120   
   97    121   
        Ok(Self(value))
   98    122   
    }
   99    123   
}
  100    124   
  101    125   
impl ::std::convert::From<ComplexSet> for ::std::vec::Vec<crate::model::ComplexSetStruct> {
  102    126   
    fn from(value: ComplexSet) -> Self {
  103    127   
        value.into_inner()
  104    128   
    }
  105    129   
}
         130  +
/* ConstrainedCollectionGenerator.kt:181 */
  106    131   
impl crate::constrained::Constrained for ComplexSet {
  107    132   
    type Unconstrained = crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained;
  108    133   
}
  109    134   
         135  +
/* StructureGenerator.kt:197 */
  110    136   
#[allow(missing_docs)] // documentation missing in model
         137  +
/* RustType.kt:516 */
  111    138   
#[derive(
  112    139   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  113    140   
)]
  114         -
pub struct ComplexSetStruct {
         141  +
pub /* StructureGenerator.kt:201 */ struct ComplexSetStruct {
         142  +
    /* StructureGenerator.kt:231 */
  115    143   
    #[allow(missing_docs)] // documentation missing in model
  116    144   
    pub foo: ::std::option::Option<bool>,
         145  +
    /* StructureGenerator.kt:231 */
  117    146   
    #[allow(missing_docs)] // documentation missing in model
  118    147   
    pub blob: ::std::option::Option<::aws_smithy_types::Blob>,
         148  +
    /* StructureGenerator.kt:201 */
  119    149   
}
         150  +
/* StructureGenerator.kt:135 */
  120    151   
impl ComplexSetStruct {
         152  +
    /* StructureGenerator.kt:231 */
  121    153   
    #[allow(missing_docs)] // documentation missing in model
         154  +
                           /* StructureGenerator.kt:166 */
  122    155   
    pub fn foo(&self) -> ::std::option::Option<bool> {
         156  +
        /* StructureGenerator.kt:168 */
  123    157   
        self.foo
         158  +
        /* StructureGenerator.kt:166 */
  124    159   
    }
         160  +
    /* StructureGenerator.kt:231 */
  125    161   
    #[allow(missing_docs)] // documentation missing in model
         162  +
                           /* StructureGenerator.kt:166 */
  126    163   
    pub fn blob(&self) -> ::std::option::Option<&::aws_smithy_types::Blob> {
         164  +
        /* StructureGenerator.kt:170 */
  127    165   
        self.blob.as_ref()
         166  +
        /* StructureGenerator.kt:166 */
  128    167   
    }
         168  +
    /* StructureGenerator.kt:135 */
  129    169   
}
         170  +
/* ServerCodegenVisitor.kt:345 */
  130    171   
impl ComplexSetStruct {
  131         -
    /// Creates a new builder-style object to manufacture [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         172  +
    /// /* ServerBuilderGenerator.kt:294 */Creates a new builder-style object to manufacture [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         173  +
    /* ServerBuilderGenerator.kt:295 */
  132    174   
    pub fn builder() -> crate::model::complex_set_struct::Builder {
         175  +
        /* ServerBuilderGenerator.kt:296 */
  133    176   
        crate::model::complex_set_struct::Builder::default()
         177  +
        /* ServerBuilderGenerator.kt:295 */
  134    178   
    }
         179  +
    /* ServerCodegenVisitor.kt:345 */
  135    180   
}
         181  +
/* ServerStructureConstrainedTraitImpl.kt:21 */
  136    182   
impl crate::constrained::Constrained for crate::model::ComplexSetStruct {
  137    183   
    type Unconstrained = crate::model::complex_set_struct::Builder;
  138    184   
}
  139    185   
         186  +
/* ConstrainedCollectionGenerator.kt:93 */
  140    187   
#[allow(missing_docs)] // documentation missing in model
  141         -
///
         188  +
/// /* ConstrainedCollectionGenerator.kt:94 */
  142    189   
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
  143    190   
/// [constraint traits]. Use [`SimpleSet::try_from`] to construct values of this type.
  144    191   
///
  145    192   
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
  146    193   
///
         194  +
/* RustType.kt:516 */
  147    195   
#[derive(
  148    196   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
  149    197   
)]
  150         -
pub struct SimpleSet(pub(crate) ::std::vec::Vec<::std::string::String>);
         198  +
pub /* ConstrainedCollectionGenerator.kt:97 */ struct SimpleSet(
         199  +
    pub(crate) ::std::vec::Vec<::std::string::String>,
         200  +
);
         201  +
/* ConstrainedCollectionGenerator.kt:104 */
  151    202   
impl SimpleSet {
         203  +
    /* ConstrainedCollectionGenerator.kt:106 */
  152    204   
    /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::string::String>`].
  153    205   
    pub fn inner(&self) -> &::std::vec::Vec<::std::string::String> {
  154    206   
        &self.0
  155    207   
    }
         208  +
    /* ConstrainedCollectionGenerator.kt:116 */
  156    209   
    /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
  157    210   
    pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
  158    211   
        self.0
  159    212   
    }
  160    213   
  161    214   
    fn check_unique_items(
  162    215   
        items: ::std::vec::Vec<::std::string::String>,
  163    216   
    ) -> ::std::result::Result<
  164    217   
        ::std::vec::Vec<::std::string::String>,
  165    218   
        crate::model::simple_set::ConstraintViolation,
  166    219   
    > {
  167    220   
        let mut seen = ::std::collections::HashMap::new();
  168    221   
        let mut duplicate_indices = ::std::vec::Vec::new();
  169    222   
        for (idx, item) in items.iter().enumerate() {
  170    223   
            if let Some(prev_idx) = seen.insert(item, idx) {
  171    224   
                duplicate_indices.push(prev_idx);
  172    225   
            }
  173    226   
        }
  174    227   
  175    228   
        let mut last_duplicate_indices = ::std::vec::Vec::new();
  176    229   
        for idx in &duplicate_indices {
  177    230   
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
  178    231   
                last_duplicate_indices.push(prev_idx);
  179    232   
            }
  180    233   
        }
  181    234   
        duplicate_indices.extend(last_duplicate_indices);
  182    235   
  183    236   
        if !duplicate_indices.is_empty() {
  184    237   
            debug_assert!(duplicate_indices.len() >= 2);
  185    238   
            Err(crate::model::simple_set::ConstraintViolation::UniqueItems {
  186    239   
                duplicate_indices,
  187    240   
                original: items,
  188    241   
            })
  189    242   
        } else {
  190    243   
            Ok(items)
  191    244   
        }
  192    245   
    }
         246  +
    /* ConstrainedCollectionGenerator.kt:104 */
  193    247   
}
         248  +
/* ConstrainedCollectionGenerator.kt:133 */
  194    249   
impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for SimpleSet {
  195    250   
    type Error = crate::model::simple_set::ConstraintViolation;
  196    251   
  197    252   
    /// Constructs a `SimpleSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
  198    253   
    fn try_from(
  199    254   
        value: ::std::vec::Vec<::std::string::String>,
  200    255   
    ) -> ::std::result::Result<Self, Self::Error> {
  201    256   
        let value = Self::check_unique_items(value)?;
  202    257   
  203    258   
        Ok(Self(value))
  204    259   
    }
  205    260   
}
  206    261   
  207    262   
impl ::std::convert::From<SimpleSet> for ::std::vec::Vec<::std::string::String> {
  208    263   
    fn from(value: SimpleSet) -> Self {
  209    264   
        value.into_inner()
  210    265   
    }
  211    266   
}
         267  +
/* ConstrainedCollectionGenerator.kt:181 */
  212    268   
impl crate::constrained::Constrained for SimpleSet {
  213    269   
    type Unconstrained = crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained;
  214    270   
}
  215    271   
  216         -
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         272  +
/// /* ServerBuilderGenerator.kt:171 */See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  217    273   
pub mod validation_exception_field {
  218    274   
         275  +
    /* RustType.kt:516 */
  219    276   
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
  220         -
    /// Holds one variant for each of the ways the builder can fail.
         277  +
    /// /* ServerBuilderConstraintViolations.kt:72 */Holds one variant for each of the ways the builder can fail.
         278  +
    /* RustType.kt:516 */
  221    279   
    #[non_exhaustive]
         280  +
    /* ServerBuilderConstraintViolations.kt:75 */
  222    281   
    #[allow(clippy::enum_variant_names)]
  223    282   
    pub enum ConstraintViolation {
  224         -
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
         283  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`path` was not provided but it is required when building `ValidationExceptionField`.
         284  +
        /* ServerBuilderConstraintViolations.kt:143 */
  225    285   
        MissingPath,
  226         -
        /// `message` was not provided but it is required when building `ValidationExceptionField`.
         286  +
        /// /* ServerBuilderConstraintViolations.kt:138 */`message` was not provided but it is required when building `ValidationExceptionField`.
         287  +
        /* ServerBuilderConstraintViolations.kt:143 */
  227    288   
        MissingMessage,
         289  +
        /* ServerBuilderConstraintViolations.kt:75 */
  228    290   
    }
         291  +
    /* ServerBuilderConstraintViolations.kt:117 */
  229    292   
    impl ::std::fmt::Display for ConstraintViolation {
         293  +
        /* ServerBuilderConstraintViolations.kt:118 */
  230    294   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         295  +
            /* ServerBuilderConstraintViolations.kt:119 */
  231    296   
            match self {
  232         -
                ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
  233         -
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
  234         -
            }
         297  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
         298  +
                /* ServerBuilderConstraintViolations.kt:127 */ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
         299  +
            /* ServerBuilderConstraintViolations.kt:119 */}
         300  +
            /* ServerBuilderConstraintViolations.kt:118 */
  235    301   
        }
         302  +
        /* ServerBuilderConstraintViolations.kt:117 */
  236    303   
    }
         304  +
    /* ServerBuilderConstraintViolations.kt:84 */
  237    305   
    impl ::std::error::Error for ConstraintViolation {}
         306  +
    /* ServerBuilderGenerator.kt:446 */
  238    307   
    impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
  239    308   
        type Error = ConstraintViolation;
  240    309   
  241    310   
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
  242    311   
            builder.build()
  243    312   
        }
  244    313   
    }
  245         -
    /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         314  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         315  +
    /* RustType.kt:516 */
  246    316   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         317  +
    /* ServerBuilderGenerator.kt:211 */
  247    318   
    pub struct Builder {
         319  +
        /* ServerBuilderGenerator.kt:308 */
  248    320   
        pub(crate) path: ::std::option::Option<::std::string::String>,
         321  +
        /* ServerBuilderGenerator.kt:308 */
  249    322   
        pub(crate) message: ::std::option::Option<::std::string::String>,
         323  +
        /* ServerBuilderGenerator.kt:211 */
  250    324   
    }
         325  +
    /* ServerBuilderGenerator.kt:215 */
  251    326   
    impl Builder {
  252         -
        /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         327  +
        /// /* ServerBuilderGenerator.kt:331 */A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         328  +
        /* ServerBuilderGenerator.kt:343 */
  253    329   
        pub fn path(mut self, input: ::std::string::String) -> Self {
  254         -
            self.path = Some(input);
         330  +
            /* ServerBuilderGenerator.kt:344 */
         331  +
            self.path =
         332  +
                /* ServerBuilderGenerator.kt:345 */Some(
         333  +
                    /* ServerBuilderGenerator.kt:376 */input
         334  +
                /* ServerBuilderGenerator.kt:345 */)
         335  +
            /* ServerBuilderGenerator.kt:344 */;
  255    336   
            self
         337  +
            /* ServerBuilderGenerator.kt:343 */
  256    338   
        }
  257         -
        /// A detailed description of the validation failure.
         339  +
        /// /* ServerBuilderGenerator.kt:331 */A detailed description of the validation failure.
         340  +
        /* ServerBuilderGenerator.kt:343 */
  258    341   
        pub fn message(mut self, input: ::std::string::String) -> Self {
  259         -
            self.message = Some(input);
         342  +
            /* ServerBuilderGenerator.kt:344 */
         343  +
            self.message =
         344  +
                /* ServerBuilderGenerator.kt:345 */Some(
         345  +
                    /* ServerBuilderGenerator.kt:376 */input
         346  +
                /* ServerBuilderGenerator.kt:345 */)
         347  +
            /* ServerBuilderGenerator.kt:344 */;
  260    348   
            self
         349  +
            /* ServerBuilderGenerator.kt:343 */
  261    350   
        }
  262         -
        /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
  263         -
        ///
         351  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         352  +
        /// /* ServerBuilderGenerator.kt:260 */
  264    353   
        /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if a [`ConstraintViolation`] occurs.
  265    354   
        ///
  266         -
        /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         355  +
        /// /* ServerBuilderGenerator.kt:268 */If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         356  +
        /* ServerBuilderGenerator.kt:271 */
  267    357   
        pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
  268    358   
            self.build_enforcing_all_constraints()
  269    359   
        }
         360  +
        /* ServerBuilderGenerator.kt:283 */
  270    361   
        fn build_enforcing_all_constraints(
  271    362   
            self,
  272    363   
        ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
  273         -
            Ok(crate::model::ValidationExceptionField {
  274         -
                path: self.path.ok_or(ConstraintViolation::MissingPath)?,
  275         -
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
  276         -
            })
         364  +
            /* ServerBuilderGenerator.kt:287 */
         365  +
            Ok(
         366  +
                /* ServerBuilderGenerator.kt:542 */
         367  +
                crate::model::ValidationExceptionField {
         368  +
                    /* ServerBuilderGenerator.kt:546 */
         369  +
                    path: self
         370  +
                        .path
         371  +
                        /* ServerBuilderGenerator.kt:569 */
         372  +
                        .ok_or(ConstraintViolation::MissingPath)?,
         373  +
                    /* ServerBuilderGenerator.kt:546 */
         374  +
                    message: self
         375  +
                        .message
         376  +
                        /* ServerBuilderGenerator.kt:569 */
         377  +
                        .ok_or(ConstraintViolation::MissingMessage)?,
         378  +
                    /* ServerBuilderGenerator.kt:542 */
         379  +
                }, /* ServerBuilderGenerator.kt:287 */
         380  +
            )
         381  +
            /* ServerBuilderGenerator.kt:283 */
  277    382   
        }
         383  +
        /* ServerBuilderGenerator.kt:215 */
  278    384   
    }
         385  +
         386  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  279    387   
}
  280         -
/// See [`ComplexSet`](crate::model::ComplexSet).
         388  +
/// /* CodegenDelegator.kt:51 */See [`ComplexSet`](crate::model::ComplexSet).
  281    389   
pub mod complex_set {
  282    390   
         391  +
    /* CollectionConstraintViolationGenerator.kt:78 */
  283    392   
    #[allow(clippy::enum_variant_names)]
  284    393   
    #[derive(Debug, PartialEq)]
  285    394   
    pub enum ConstraintViolation {
  286    395   
        /// Constraint violation error when the list does not contain unique items
  287    396   
        UniqueItems {
  288    397   
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
  289    398   
            /// at least two elements.
  290    399   
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
  291    400   
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
  292    401   
            /// Nothing is guaranteed about the order of the indices.
  293    402   
            duplicate_indices: ::std::vec::Vec<usize>,
  294    403   
            /// The original vector, that contains duplicate items.
  295    404   
            original: ::std::vec::Vec<crate::model::ComplexSetStruct>,
  296    405   
        },
  297    406   
    }
  298    407   
  299    408   
    impl ::std::fmt::Display for ConstraintViolation {
  300    409   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  301    410   
            let message = match self {
  302    411   
                                Self::UniqueItems { duplicate_indices, .. } =>
  303    412   
                            format!("Value with repeated values at indices {:?} provided for 'com.amazonaws.constraints#ComplexSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
  304    413   
                            };
  305    414   
            write!(f, "{message}")
  306    415   
        }
  307    416   
    }
  308    417   
  309    418   
    impl ::std::error::Error for ConstraintViolation {}
         419  +
    /* CollectionConstraintViolationGenerator.kt:104 */
  310    420   
    impl ConstraintViolation {
  311    421   
        pub(crate) fn as_validation_exception_field(
  312    422   
            self,
  313    423   
            path: ::std::string::String,
  314    424   
        ) -> crate::model::ValidationExceptionField {
  315    425   
            match self {
  316    426   
                        Self::UniqueItems { duplicate_indices, .. } =>
  317    427   
                                crate::model::ValidationExceptionField {
  318    428   
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
  319    429   
                                    path,
  320    430   
                                },
  321    431   
                    }
  322    432   
        }
  323    433   
    }
         434  +
         435  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  324    436   
}
  325         -
/// See [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         437  +
/// /* ServerBuilderGenerator.kt:171 */See [`ComplexSetStruct`](crate::model::ComplexSetStruct).
  326    438   
pub mod complex_set_struct {
  327    439   
         440  +
    /* ServerBuilderGenerator.kt:461 */
  328    441   
    impl ::std::convert::From<Builder> for crate::model::ComplexSetStruct {
  329    442   
        fn from(builder: Builder) -> Self {
  330    443   
            builder.build()
  331    444   
        }
  332    445   
    }
  333         -
    /// A builder for [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         446  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         447  +
    /* RustType.kt:516 */
  334    448   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         449  +
    /* ServerBuilderGenerator.kt:211 */
  335    450   
    pub struct Builder {
  336         -
        pub(crate) foo: ::std::option::Option<bool>,
         451  +
        /* ServerBuilderGenerator.kt:308 */ pub(crate) foo: ::std::option::Option<bool>,
         452  +
        /* ServerBuilderGenerator.kt:308 */
  337    453   
        pub(crate) blob: ::std::option::Option<::aws_smithy_types::Blob>,
         454  +
        /* ServerBuilderGenerator.kt:211 */
  338    455   
    }
         456  +
    /* ServerBuilderGenerator.kt:215 */
  339    457   
    impl Builder {
         458  +
        /* ServerBuilderGenerator.kt:331 */
  340    459   
        #[allow(missing_docs)] // documentation missing in model
         460  +
                               /* ServerBuilderGenerator.kt:343 */
  341    461   
        pub fn foo(mut self, input: ::std::option::Option<bool>) -> Self {
  342         -
            self.foo = input;
         462  +
            /* ServerBuilderGenerator.kt:344 */
         463  +
            self.foo =
         464  +
                /* ServerBuilderGenerator.kt:376 */input
         465  +
            /* ServerBuilderGenerator.kt:344 */;
  343    466   
            self
         467  +
            /* ServerBuilderGenerator.kt:343 */
  344    468   
        }
         469  +
        /* ServerBuilderGenerator.kt:426 */
  345    470   
        #[allow(missing_docs)] // documentation missing in model
         471  +
                               /* ServerBuilderGenerator.kt:428 */
  346    472   
        pub(crate) fn set_foo(mut self, input: Option<impl ::std::convert::Into<bool>>) -> Self {
         473  +
            /* ServerBuilderGenerator.kt:429 */
  347    474   
            self.foo = input.map(|v| v.into());
  348    475   
            self
         476  +
            /* ServerBuilderGenerator.kt:428 */
  349    477   
        }
         478  +
        /* ServerBuilderGenerator.kt:331 */
  350    479   
        #[allow(missing_docs)] // documentation missing in model
         480  +
                               /* ServerBuilderGenerator.kt:343 */
  351    481   
        pub fn blob(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
  352         -
            self.blob = input;
         482  +
            /* ServerBuilderGenerator.kt:344 */
         483  +
            self.blob =
         484  +
                /* ServerBuilderGenerator.kt:376 */input
         485  +
            /* ServerBuilderGenerator.kt:344 */;
  353    486   
            self
         487  +
            /* ServerBuilderGenerator.kt:343 */
  354    488   
        }
         489  +
        /* ServerBuilderGenerator.kt:426 */
  355    490   
        #[allow(missing_docs)] // documentation missing in model
         491  +
                               /* ServerBuilderGenerator.kt:428 */
  356    492   
        pub(crate) fn set_blob(
  357    493   
            mut self,
  358    494   
            input: Option<impl ::std::convert::Into<::aws_smithy_types::Blob>>,
  359    495   
        ) -> Self {
         496  +
            /* ServerBuilderGenerator.kt:429 */
  360    497   
            self.blob = input.map(|v| v.into());
  361    498   
            self
         499  +
            /* ServerBuilderGenerator.kt:428 */
  362    500   
        }
  363         -
        /// Consumes the builder and constructs a [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         501  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         502  +
        /* ServerBuilderGenerator.kt:271 */
  364    503   
        pub fn build(self) -> crate::model::ComplexSetStruct {
  365    504   
            self.build_enforcing_all_constraints()
  366    505   
        }
         506  +
        /* ServerBuilderGenerator.kt:283 */
  367    507   
        fn build_enforcing_all_constraints(self) -> crate::model::ComplexSetStruct {
         508  +
            /* ServerBuilderGenerator.kt:542 */
  368    509   
            crate::model::ComplexSetStruct {
         510  +
                /* ServerBuilderGenerator.kt:546 */
  369    511   
                foo: self.foo,
         512  +
                /* ServerBuilderGenerator.kt:546 */
  370    513   
                blob: self.blob,
         514  +
                /* ServerBuilderGenerator.kt:542 */
  371    515   
            }
         516  +
            /* ServerBuilderGenerator.kt:283 */
  372    517   
        }
         518  +
        /* ServerBuilderGenerator.kt:215 */
  373    519   
    }
         520  +
         521  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  374    522   
}
  375         -
/// See [`SimpleSet`](crate::model::SimpleSet).
         523  +
/// /* CodegenDelegator.kt:51 */See [`SimpleSet`](crate::model::SimpleSet).
  376    524   
pub mod simple_set {
  377    525   
         526  +
    /* CollectionConstraintViolationGenerator.kt:78 */
  378    527   
    #[allow(clippy::enum_variant_names)]
  379    528   
    #[derive(Debug, PartialEq)]
  380    529   
    pub enum ConstraintViolation {
  381    530   
        /// Constraint violation error when the list does not contain unique items
  382    531   
        UniqueItems {
  383    532   
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
  384    533   
            /// at least two elements.
  385    534   
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
  386    535   
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
  387    536   
            /// Nothing is guaranteed about the order of the indices.
  388    537   
            duplicate_indices: ::std::vec::Vec<usize>,
  389    538   
            /// The original vector, that contains duplicate items.
  390    539   
            original: ::std::vec::Vec<::std::string::String>,
  391    540   
        },
  392    541   
    }
  393    542   
  394    543   
    impl ::std::fmt::Display for ConstraintViolation {
  395    544   
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  396    545   
            let message = match self {
  397    546   
                                Self::UniqueItems { duplicate_indices, .. } =>
  398    547   
                            format!("Value with repeated values at indices {:?} provided for 'com.amazonaws.constraints#SimpleSet' failed to satisfy constraint: Member must have unique values", &duplicate_indices),
  399    548   
                            };
  400    549   
            write!(f, "{message}")
  401    550   
        }
  402    551   
    }
  403    552   
  404    553   
    impl ::std::error::Error for ConstraintViolation {}
         554  +
    /* CollectionConstraintViolationGenerator.kt:104 */
  405    555   
    impl ConstraintViolation {
  406    556   
        pub(crate) fn as_validation_exception_field(
  407    557   
            self,
  408    558   
            path: ::std::string::String,
  409    559   
        ) -> crate::model::ValidationExceptionField {
  410    560   
            match self {
  411    561   
                        Self::UniqueItems { duplicate_indices, .. } =>
  412    562   
                                crate::model::ValidationExceptionField {
  413    563   
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
  414    564   
                                    path,
  415    565   
                                },
  416    566   
                    }
  417    567   
        }
  418    568   
    }
         569  +
         570  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
  419    571   
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/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_MALFORMEDUNIQUEITEMS: ::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   
    /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
    6      7   
    pub struct MalformedUniqueItemsInputFuture {
    7      8   
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedUniqueItemsInput, ::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 MalformedUniqueItemsInputFuture {
@@ -38,39 +133,139 @@
   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   
        MalformedUniqueItemsInputFuture {
   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::MalformedUniqueItemsOutput
   72     74   
{
   73     75   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   74     76   
        match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_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::MalformedUniqueItemsError
   87     90   
{
   88     91   
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   89     92   
        match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
   90     93   
            Ok(mut response) => {
   91     94   
                response.extensions_mut().insert(::aws_smithy_http_server::extension::ModeledErrorExtension::new(self.name()));
   92     95   
                response
   93     96   
            },
   94     97   
            Err(e) => {
   95     98   
                ::tracing::error!(error = %e, "failed to serialize response");
   96     99   
                ::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))
   97    100   
            }
   98    101   
        }
   99    102   
    }
  100    103   
}
  101    104   
         105  +
/* RustType.kt:516 */
  102    106   
#[allow(unreachable_code, unused_variables)]
         107  +
/* RustType.kt:516 */
  103    108   
#[cfg(test)]
         109  +
/* ProtocolTestGenerator.kt:98 */
  104    110   
mod malformed_unique_items_test {
  105    111   
  106    112   
    /// When the list has duplicated items, the response should be a 400
  107    113   
    /// ValidationException.
  108    114   
    /// Test ID: RestJsonMalformedUniqueItemsDuplicateItems
  109    115   
    #[::tokio::test]
  110    116   
    #[::tracing_test::traced_test]
  111    117   
    async fn rest_json_malformed_unique_items_duplicate_items_malformed_request() {
  112    118   
        {
  113    119   
            #[allow(unused_mut)]
@@ -179,185 +209,217 @@
  199    205   
                expected_headers,
  200    206   
            ));
  201    207   
            let body = ::hyper::body::to_bytes(http_response.into_body())
  202    208   
                .await
  203    209   
                .expect("unable to extract body to bytes");
  204    210   
            ::aws_smithy_protocol_test::assert_ok(
  205    211   
            ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\",\n  \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\", \"path\": \"/complexSet\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
  206    212   
            );
  207    213   
        }
  208    214   
    }
         215  +
         216  +
    /* ProtocolTestGenerator.kt:98 */
  209    217   
}

tmp-codegen-diff/codegen-server-test/unique_items/rust-server-codegen/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 MalformedUniqueItems;
    4      6   
    5      7   
impl ::aws_smithy_http_server::operation::OperationShape for MalformedUniqueItems {
    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.constraints#MalformedUniqueItems",
    9     11   
            "com.amazonaws.constraints",
   10     12   
            "MalformedUniqueItems",
   11     13   
        );
   12     14   
   13     15   
    type Input = crate::input::MalformedUniqueItemsInput;
   14     16   
    type Output = crate::output::MalformedUniqueItemsOutput;
   15     17   
    type Error = crate::error::MalformedUniqueItemsError;
   16     18   
}
   17     19   
   18     20   
impl ::aws_smithy_http_server::instrumentation::sensitivity::Sensitivity for MalformedUniqueItems {
   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/unique_items/rust-server-codegen/src/output.rs

@@ -1,1 +33,52 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/* StructureGenerator.kt:197 */
    2      3   
#[allow(missing_docs)] // documentation missing in model
           4  +
/* RustType.kt:516 */
    3      5   
#[derive(
    4      6   
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
    5      7   
)]
    6         -
pub struct MalformedUniqueItemsOutput {}
           8  +
pub /* StructureGenerator.kt:201 */ struct MalformedUniqueItemsOutput {/* StructureGenerator.kt:201 */}
           9  +
/* ServerCodegenVisitor.kt:345 */
    7     10   
impl MalformedUniqueItemsOutput {
    8         -
    /// Creates a new builder-style object to manufacture [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          11  +
    /// /* ServerBuilderGenerator.kt:294 */Creates a new builder-style object to manufacture [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          12  +
    /* ServerBuilderGenerator.kt:295 */
    9     13   
    pub fn builder() -> crate::output::malformed_unique_items_output::Builder {
          14  +
        /* ServerBuilderGenerator.kt:296 */
   10     15   
        crate::output::malformed_unique_items_output::Builder::default()
          16  +
        /* ServerBuilderGenerator.kt:295 */
   11     17   
    }
          18  +
    /* ServerCodegenVisitor.kt:345 */
   12     19   
}
   13         -
/// See [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          20  +
/// /* ServerBuilderGenerator.kt:171 */See [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
   14     21   
pub mod malformed_unique_items_output {
   15     22   
          23  +
    /* ServerBuilderGenerator.kt:461 */
   16     24   
    impl ::std::convert::From<Builder> for crate::output::MalformedUniqueItemsOutput {
   17     25   
        fn from(builder: Builder) -> Self {
   18     26   
            builder.build()
   19     27   
        }
   20     28   
    }
   21         -
    /// A builder for [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          29  +
    /// /* ServerBuilderGenerator.kt:201 */A builder for [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          30  +
    /* RustType.kt:516 */
   22     31   
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
   23         -
    pub struct Builder {}
          32  +
    /* ServerBuilderGenerator.kt:211 */
          33  +
    pub struct Builder {/* ServerBuilderGenerator.kt:211 */}
          34  +
    /* ServerBuilderGenerator.kt:215 */
   24     35   
    impl Builder {
   25         -
        /// Consumes the builder and constructs a [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          36  +
        /// /* ServerBuilderGenerator.kt:258 */Consumes the builder and constructs a [`MalformedUniqueItemsOutput`](crate::output::MalformedUniqueItemsOutput).
          37  +
        /* ServerBuilderGenerator.kt:271 */
   26     38   
        pub fn build(self) -> crate::output::MalformedUniqueItemsOutput {
   27     39   
            self.build_enforcing_all_constraints()
   28     40   
        }
          41  +
        /* ServerBuilderGenerator.kt:283 */
   29     42   
        fn build_enforcing_all_constraints(self) -> crate::output::MalformedUniqueItemsOutput {
   30         -
            crate::output::MalformedUniqueItemsOutput {}
          43  +
            /* ServerBuilderGenerator.kt:542 */
          44  +
            crate::output::MalformedUniqueItemsOutput {
          45  +
            /* ServerBuilderGenerator.kt:542 */}
          46  +
            /* ServerBuilderGenerator.kt:283 */
   31     47   
        }
          48  +
        /* ServerBuilderGenerator.kt:215 */
   32     49   
    }
          50  +
          51  +
    /* RustCrateInlineModuleComposingWriter.kt:299 */
   33     52   
}

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

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