Server Test

Server Test

rev. 03e6e47f15dfd569240d570d98975ebba692c405 (ignoring whitespace)

Files changed:

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

@@ -11,11 +71,71 @@
   31     31   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   32     32   
    B: 'static,
   33     33   
   34     34   
    B::Data: Send,
   35     35   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   36     36   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   37     37   
{
   38     38   
    type Rejection = ::aws_smithy_http_server::protocol::rest_json_1::runtime_error::RuntimeError;
   39     39   
    type Future = OperationInputFuture;
   40     40   
   41         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
          41  +
    fn from_request(request: ::http_1x::Request<B>) -> Self::Future {
   42     42   
        let fut = async move {
   43     43   
            if !::aws_smithy_http_server::protocol::accept_header_classifier(
   44     44   
                request.headers(),
   45     45   
                &crate::mimes::CONTENT_TYPE_APPLICATION_JSON,
   46     46   
            ) {
   47     47   
                return Err(::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
   48     48   
            }
   49     49   
            crate::protocol_serde::shape_operation::de_operation_http_request(request).await
   50     50   
        };
   51     51   
        use ::futures_util::future::TryFutureExt;

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

@@ -1,1 +88,91 @@
    1      1   
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2      2   
#[allow(clippy::unnecessary_wraps)]
    3      3   
pub async fn de_operation_http_request<B>(
    4         -
    #[allow(unused_variables)] request: ::http::Request<B>,
           4  +
    #[allow(unused_variables)] request: ::http_1x::Request<B>,
    5      5   
) -> std::result::Result<
    6      6   
    crate::input::OperationInput,
    7      7   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
    8      8   
>
    9      9   
where
   10     10   
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   11     11   
    B::Data: Send,
   12     12   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
   13     13   
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   14     14   
{
   15     15   
    Ok({
   16     16   
        #[allow(unused_mut)]
   17     17   
        let mut input = crate::input::operation_input::Builder::default();
   18     18   
        #[allow(unused_variables)]
   19     19   
        let ::aws_smithy_runtime_api::http::RequestParts {
   20     20   
            uri, headers, body, ..
   21     21   
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
   22         -
        let bytes = ::hyper::body::to_bytes(body).await?;
          22  +
        let bytes = {
          23  +
            use ::http_body_util::BodyExt;
          24  +
            body.collect().await?.to_bytes()
          25  +
        };
   23     26   
        if !bytes.is_empty() {
   24     27   
            ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
   25     28   
                &headers,
   26     29   
                Some("application/json"),
   27     30   
            )?;
   28     31   
            input = crate::protocol_serde::shape_operation::de_operation(bytes.as_ref(), input)?;
   29     32   
        }
   30     33   
        input.build()
   31     34   
    })
   32     35   
}
   33     36   
   34     37   
#[allow(clippy::unnecessary_wraps)]
   35     38   
pub fn ser_operation_http_response(
   36     39   
    #[allow(unused_variables)] output: crate::output::OperationOutput,
   37     40   
) -> std::result::Result<
   38     41   
    ::aws_smithy_http_server::response::Response,
   39     42   
    ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
   40     43   
> {
   41     44   
    Ok({
   42     45   
        #[allow(unused_mut)]
   43         -
        let mut builder = ::http::Response::builder();
          46  +
        let mut builder = ::http_1x::Response::builder();
   44     47   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   45     48   
            builder,
   46         -
            ::http::header::CONTENT_TYPE,
          49  +
            ::http_1x::header::CONTENT_TYPE,
   47     50   
            "application/json",
   48     51   
        );
   49     52   
        let http_status: u16 = 200;
   50     53   
        builder = builder.status(http_status);
   51     54   
        let payload =
   52     55   
            crate::protocol_serde::shape_operation_output::ser_operation_output_output_output(
   53     56   
                &output,
   54     57   
            )?;
   55     58   
        let content_length = payload.len();
   56     59   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   57     60   
            builder,
   58         -
            ::http::header::CONTENT_LENGTH,
          61  +
            ::http_1x::header::CONTENT_LENGTH,
   59     62   
            content_length,
   60     63   
        );
   61     64   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
   62     65   
        builder.body(body)?
   63     66   
    })
   64     67   
}
   65     68   
   66     69   
pub(crate) fn de_operation(
   67     70   
    value: &[u8],
   68     71   
    mut builder: crate::input::operation_input::Builder,

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

@@ -35,35 +96,96 @@
   55     55   
                            <
   56     56   
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
   57     57   
                                as ::aws_smithy_http_server::plugin::Plugin<
   58     58   
                                    SimpleService<L>,
   59     59   
                                    crate::operation_shape::Operation,
   60     60   
                                    ModelPl::Output
   61     61   
                                >
   62     62   
                            >::Output
   63     63   
                        >,
   64     64   
   65         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
   66         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
          65  +
                        HttpPl::Output: ::tower::Service<::http_1x::Request<Body>, Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
          66  +
                        <HttpPl::Output as ::tower::Service<::http_1x::Request<Body>>>::Future: Send + 'static,
   67     67   
   68     68   
                    {
   69     69   
        use ::aws_smithy_http_server::operation::OperationShapeExt;
   70     70   
        use ::aws_smithy_http_server::plugin::Plugin;
   71     71   
        let svc = crate::operation_shape::Operation::from_handler(handler);
   72     72   
        let svc = self.model_plugin.apply(svc);
   73     73   
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
   74     74   
            .apply(svc);
   75     75   
        let svc = self.http_plugin.apply(svc);
   76     76   
        self.operation_custom(svc)
@@ -102,102 +182,182 @@
  122    122   
                            <
  123    123   
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
  124    124   
                                as ::aws_smithy_http_server::plugin::Plugin<
  125    125   
                                    SimpleService<L>,
  126    126   
                                    crate::operation_shape::Operation,
  127    127   
                                    ModelPl::Output
  128    128   
                                >
  129    129   
                            >::Output
  130    130   
                        >,
  131    131   
  132         -
                        HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
  133         -
                        <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
         132  +
                        HttpPl::Output: ::tower::Service<::http_1x::Request<Body>, Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
         133  +
                        <HttpPl::Output as ::tower::Service<::http_1x::Request<Body>>>::Future: Send + 'static,
  134    134   
  135    135   
                    {
  136    136   
        use ::aws_smithy_http_server::operation::OperationShapeExt;
  137    137   
        use ::aws_smithy_http_server::plugin::Plugin;
  138    138   
        let svc = crate::operation_shape::Operation::from_service(service);
  139    139   
        let svc = self.model_plugin.apply(svc);
  140    140   
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
  141    141   
            .apply(svc);
  142    142   
        let svc = self.http_plugin.apply(svc);
  143    143   
        self.operation_custom(svc)
  144    144   
    }
  145    145   
  146    146   
    /// Sets the [`Operation`](crate::operation_shape::Operation) to a custom [`Service`](tower::Service).
  147    147   
    /// not constrained by the Smithy contract.
  148    148   
    fn operation_custom<S>(mut self, svc: S) -> Self
  149    149   
    where
  150    150   
        S: ::tower::Service<
  151         -
                ::http::Request<Body>,
  152         -
                Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
         151  +
                ::http_1x::Request<Body>,
         152  +
                Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>,
  153    153   
                Error = ::std::convert::Infallible,
  154    154   
            > + Clone
  155    155   
            + Send
  156    156   
            + 'static,
  157    157   
        S::Future: Send + 'static,
  158    158   
    {
  159    159   
        self.operation = Some(::aws_smithy_http_server::routing::Route::new(svc));
  160    160   
        self
  161    161   
    }
  162    162   
}
@@ -246,246 +306,306 @@
  266    266   
        }
  267    267   
        Ok(())
  268    268   
    }
  269    269   
}
  270    270   
  271    271   
impl std::error::Error for MissingOperationsError {}
  272    272   
  273    273   
mod request_specs {
  274    274   
    pub(super) fn operation() -> ::aws_smithy_http_server::routing::request_spec::RequestSpec {
  275    275   
        ::aws_smithy_http_server::routing::request_spec::RequestSpec::new(
  276         -
                    ::http::Method::POST,
         276  +
                    ::http_1x::Method::POST,
  277    277   
                    ::aws_smithy_http_server::routing::request_spec::UriSpec::new(
  278    278   
                        ::aws_smithy_http_server::routing::request_spec::PathAndQuerySpec::new(
  279    279   
                            ::aws_smithy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
  280    280   
    ::aws_smithy_http_server::routing::request_spec::PathSegment::Literal(String::from("operation")),
  281    281   
]),
  282    282   
                            ::aws_smithy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
  283    283   
])
  284    284   
                        )
  285    285   
                    ),
  286    286   
                )
@@ -403,403 +464,464 @@
  423    423   
    ) -> SimpleService<
  424    424   
        ::aws_smithy_http_server::routing::RoutingService<
  425    425   
            ::aws_smithy_http_server::protocol::rest::router::RestRouter<
  426    426   
                ::aws_smithy_http_server::routing::Route<B>,
  427    427   
            >,
  428    428   
            ::aws_smithy_http_server::protocol::rest_json_1::RestJson1,
  429    429   
        >,
  430    430   
    >
  431    431   
    where
  432    432   
        S: ::tower::Service<
  433         -
            ::http::Request<B>,
  434         -
            Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
         433  +
            ::http_1x::Request<B>,
         434  +
            Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>,
  435    435   
            Error = std::convert::Infallible,
  436    436   
        >,
  437    437   
        S: Clone + Send + 'static,
  438    438   
        S::Future: Send + 'static,
  439    439   
    {
  440    440   
        self.layer(&::tower::layer::layer_fn(
  441    441   
            ::aws_smithy_http_server::routing::Route::new,
  442    442   
        ))
  443    443   
    }
  444    444   
}

tmp-codegen-diff/codegen-server-test/unique_items-http0x/rust-server-codegen/Cargo.toml

@@ -0,1 +0,56 @@
           1  +
# Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
[package]
           3  +
name = "unique_items-http0x"
           4  +
version = "0.0.1"
           5  +
authors = ["protocoltest@example.com"]
           6  +
description = "test"
           7  +
edition = "2021"
           8  +
           9  +
[package.metadata.smithy]
          10  +
codegen-version = "ci"
          11  +
protocol = "aws.protocols#restJson1"
          12  +
[dependencies.aws-smithy-json]
          13  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
          14  +
[dependencies.aws-smithy-legacy-http]
          15  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-legacy-http"
          16  +
[dependencies.aws-smithy-legacy-http-server]
          17  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-legacy-http-server"
          18  +
[dependencies.aws-smithy-runtime-api]
          19  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
          20  +
features = ["http-02x"]
          21  +
[dependencies.aws-smithy-types]
          22  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
          23  +
features = ["http-body-0-4-x"]
          24  +
[dependencies.futures-util]
          25  +
version = "0.3"
          26  +
[dependencies.http]
          27  +
version = "0.2.9"
          28  +
[dependencies.hyper]
          29  +
version = "0.14.26"
          30  +
[dependencies.mime]
          31  +
version = "0.3"
          32  +
[dependencies.pin-project-lite]
          33  +
version = "0.2"
          34  +
[dependencies.tower]
          35  +
version = "0.4"
          36  +
[dependencies.tracing]
          37  +
version = "0.1"
          38  +
[dev-dependencies.aws-smithy-protocol-test]
          39  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-protocol-test"
          40  +
[dev-dependencies.bytes]
          41  +
version = "1.4.0"
          42  +
[dev-dependencies.pretty_assertions]
          43  +
version = "1.3.0"
          44  +
[dev-dependencies.tokio]
          45  +
version = "1.23.1"
          46  +
features = ["macros", "test-util", "rt-multi-thread"]
          47  +
[dev-dependencies.tracing-test]
          48  +
version = "0.2.5"
          49  +
features = ["no-env-filter"]
          50  +
[features]
          51  +
rt-tokio = ["aws-smithy-types/rt-tokio"]
          52  +
aws-lambda = ["aws-smithy-legacy-http-server/aws-lambda"]
          53  +
request-id = ["aws-smithy-legacy-http-server/request-id"]
          54  +
default = ["rt-tokio", "request-id"]
          55  +
          56  +

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

@@ -0,1 +0,16 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/*
           3  +
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
           4  +
 * SPDX-License-Identifier: Apache-2.0
           5  +
 */
           6  +
           7  +
pub(crate) trait Constrained {
           8  +
    type Unconstrained;
           9  +
}
          10  +
          11  +
#[derive(Debug, Clone)]
          12  +
#[allow(dead_code)]
          13  +
pub(crate) enum MaybeConstrained<T: Constrained> {
          14  +
    Constrained(T),
          15  +
    Unconstrained(T::Unconstrained),
          16  +
}

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

@@ -0,1 +0,149 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
/// Error type for the `MalformedUniqueItems` operation.
           3  +
/// Each variant represents an error that can occur for the `MalformedUniqueItems` operation.
           4  +
#[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.
           7  +
    ValidationException(crate::error::ValidationException),
           8  +
}
           9  +
impl ::std::fmt::Display for MalformedUniqueItemsError {
          10  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          11  +
        match &self {
          12  +
            MalformedUniqueItemsError::ValidationException(_inner) => _inner.fmt(f),
          13  +
        }
          14  +
    }
          15  +
}
          16  +
impl MalformedUniqueItemsError {
          17  +
    /// Returns `true` if the error kind is `MalformedUniqueItemsError::ValidationException`.
          18  +
    pub fn is_validation_exception(&self) -> bool {
          19  +
        matches!(&self, MalformedUniqueItemsError::ValidationException(_))
          20  +
    }
          21  +
    /// Returns the error name string by matching the correct variant.
          22  +
    pub fn name(&self) -> &'static str {
          23  +
        match &self {
          24  +
            MalformedUniqueItemsError::ValidationException(_inner) => _inner.name(),
          25  +
        }
          26  +
    }
          27  +
}
          28  +
impl ::std::error::Error for MalformedUniqueItemsError {
          29  +
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
          30  +
        match &self {
          31  +
            MalformedUniqueItemsError::ValidationException(_inner) => Some(_inner),
          32  +
        }
          33  +
    }
          34  +
}
          35  +
impl ::std::convert::From<crate::error::ValidationException>
          36  +
    for crate::error::MalformedUniqueItemsError
          37  +
{
          38  +
    fn from(variant: crate::error::ValidationException) -> crate::error::MalformedUniqueItemsError {
          39  +
        Self::ValidationException(variant)
          40  +
    }
          41  +
}
          42  +
          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.
          44  +
#[derive(
          45  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          46  +
)]
          47  +
pub struct ValidationException {
          48  +
    /// A summary of the validation failure.
          49  +
    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.
          51  +
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
          52  +
}
          53  +
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.
          55  +
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
          56  +
        self.field_list.as_deref()
          57  +
    }
          58  +
}
          59  +
impl ValidationException {
          60  +
    /// Returns the error message.
          61  +
    pub fn message(&self) -> &str {
          62  +
        &self.message
          63  +
    }
          64  +
    #[doc(hidden)]
          65  +
    /// Returns the error name.
          66  +
    pub fn name(&self) -> &'static str {
          67  +
        "ValidationException"
          68  +
    }
          69  +
}
          70  +
impl ::std::fmt::Display for ValidationException {
          71  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          72  +
        ::std::write!(f, "ValidationException")?;
          73  +
        {
          74  +
            ::std::write!(f, ": {}", &self.message)?;
          75  +
        }
          76  +
        Ok(())
          77  +
    }
          78  +
}
          79  +
impl ::std::error::Error for ValidationException {}
          80  +
impl ValidationException {
          81  +
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
          82  +
    pub fn builder() -> crate::error::validation_exception::Builder {
          83  +
        crate::error::validation_exception::Builder::default()
          84  +
    }
          85  +
}
          86  +
/// See [`ValidationException`](crate::error::ValidationException).
          87  +
pub mod validation_exception {
          88  +
          89  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
          90  +
    /// Holds one variant for each of the ways the builder can fail.
          91  +
    #[non_exhaustive]
          92  +
    #[allow(clippy::enum_variant_names)]
          93  +
    pub enum ConstraintViolation {
          94  +
        /// `message` was not provided but it is required when building `ValidationException`.
          95  +
        MissingMessage,
          96  +
    }
          97  +
    impl ::std::fmt::Display for ConstraintViolation {
          98  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          99  +
            match self {
         100  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
         101  +
            }
         102  +
        }
         103  +
    }
         104  +
    impl ::std::error::Error for ConstraintViolation {}
         105  +
    impl ::std::convert::TryFrom<Builder> for crate::error::ValidationException {
         106  +
        type Error = ConstraintViolation;
         107  +
         108  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         109  +
            builder.build()
         110  +
        }
         111  +
    }
         112  +
    /// A builder for [`ValidationException`](crate::error::ValidationException).
         113  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         114  +
    pub struct Builder {
         115  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         116  +
        pub(crate) field_list:
         117  +
            ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         118  +
    }
         119  +
    impl Builder {
         120  +
        /// A summary of the validation failure.
         121  +
        pub fn message(mut self, input: ::std::string::String) -> Self {
         122  +
            self.message = Some(input);
         123  +
            self
         124  +
        }
         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.
         126  +
        pub fn field_list(
         127  +
            mut self,
         128  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         129  +
        ) -> Self {
         130  +
            self.field_list = input;
         131  +
            self
         132  +
        }
         133  +
        /// Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
         134  +
        ///
         135  +
        /// The builder fails to construct a [`ValidationException`](crate::error::ValidationException) if a [`ConstraintViolation`] occurs.
         136  +
        ///
         137  +
        pub fn build(self) -> Result<crate::error::ValidationException, ConstraintViolation> {
         138  +
            self.build_enforcing_all_constraints()
         139  +
        }
         140  +
        fn build_enforcing_all_constraints(
         141  +
            self,
         142  +
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
         143  +
            Ok(crate::error::ValidationException {
         144  +
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         145  +
                field_list: self.field_list,
         146  +
            })
         147  +
        }
         148  +
    }
         149  +
}

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

@@ -0,1 +0,178 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
#[derive(
           4  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
           5  +
)]
           6  +
pub struct MalformedUniqueItemsInput {
           7  +
    #[allow(missing_docs)] // documentation missing in model
           8  +
    pub set: ::std::option::Option<crate::model::SimpleSet>,
           9  +
    #[allow(missing_docs)] // documentation missing in model
          10  +
    pub complex_set: ::std::option::Option<crate::model::ComplexSet>,
          11  +
}
          12  +
impl MalformedUniqueItemsInput {
          13  +
    #[allow(missing_docs)] // documentation missing in model
          14  +
    pub fn set(&self) -> ::std::option::Option<&crate::model::SimpleSet> {
          15  +
        self.set.as_ref()
          16  +
    }
          17  +
    #[allow(missing_docs)] // documentation missing in model
          18  +
    pub fn complex_set(&self) -> ::std::option::Option<&crate::model::ComplexSet> {
          19  +
        self.complex_set.as_ref()
          20  +
    }
          21  +
}
          22  +
impl MalformedUniqueItemsInput {
          23  +
    /// Creates a new builder-style object to manufacture [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
          24  +
    pub fn builder() -> crate::input::malformed_unique_items_input::Builder {
          25  +
        crate::input::malformed_unique_items_input::Builder::default()
          26  +
    }
          27  +
}
          28  +
impl crate::constrained::Constrained for crate::input::MalformedUniqueItemsInput {
          29  +
    type Unconstrained = crate::input::malformed_unique_items_input::Builder;
          30  +
}
          31  +
/// See [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
          32  +
pub mod malformed_unique_items_input {
          33  +
          34  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
          35  +
    /// Holds one variant for each of the ways the builder can fail.
          36  +
    #[non_exhaustive]
          37  +
    #[allow(clippy::enum_variant_names)]
          38  +
    pub enum ConstraintViolation {
          39  +
        /// Constraint violation occurred building member `set` when building `MalformedUniqueItemsInput`.
          40  +
        #[doc(hidden)]
          41  +
        Set(crate::model::simple_set::ConstraintViolation),
          42  +
        /// Constraint violation occurred building member `complex_set` when building `MalformedUniqueItemsInput`.
          43  +
        #[doc(hidden)]
          44  +
        ComplexSet(crate::model::complex_set::ConstraintViolation),
          45  +
    }
          46  +
    impl ::std::fmt::Display for ConstraintViolation {
          47  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          48  +
            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  +
            }
          52  +
        }
          53  +
    }
          54  +
    impl ::std::error::Error for ConstraintViolation {}
          55  +
    impl ConstraintViolation {
          56  +
        pub(crate) fn as_validation_exception_field(
          57  +
            self,
          58  +
            path: ::std::string::String,
          59  +
        ) -> crate::model::ValidationExceptionField {
          60  +
            match self {
          61  +
                ConstraintViolation::Set(inner) => {
          62  +
                    inner.as_validation_exception_field(path + "/set")
          63  +
                }
          64  +
                ConstraintViolation::ComplexSet(inner) => {
          65  +
                    inner.as_validation_exception_field(path + "/complexSet")
          66  +
                }
          67  +
            }
          68  +
        }
          69  +
    }
          70  +
    impl ::std::convert::From<ConstraintViolation>
          71  +
        for ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection
          72  +
    {
          73  +
        fn from(constraint_violation: ConstraintViolation) -> Self {
          74  +
            let first_validation_exception_field =
          75  +
                constraint_violation.as_validation_exception_field("".to_owned());
          76  +
            let validation_exception = crate::error::ValidationException {
          77  +
                message: format!(
          78  +
                    "1 validation error detected. {}",
          79  +
                    &first_validation_exception_field.message
          80  +
                ),
          81  +
                field_list: Some(vec![first_validation_exception_field]),
          82  +
            };
          83  +
            Self::ConstraintViolation(
          84  +
                                crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(&validation_exception)
          85  +
                                    .expect("validation exceptions should never fail to serialize; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues")
          86  +
                            )
          87  +
        }
          88  +
    }
          89  +
    impl ::std::convert::From<Builder>
          90  +
        for crate::constrained::MaybeConstrained<crate::input::MalformedUniqueItemsInput>
          91  +
    {
          92  +
        fn from(builder: Builder) -> Self {
          93  +
            Self::Unconstrained(builder)
          94  +
        }
          95  +
    }
          96  +
    impl ::std::convert::TryFrom<Builder> for crate::input::MalformedUniqueItemsInput {
          97  +
        type Error = ConstraintViolation;
          98  +
          99  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         100  +
            builder.build()
         101  +
        }
         102  +
    }
         103  +
    /// A builder for [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
         104  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         105  +
    pub struct Builder {
         106  +
        pub(crate) set:
         107  +
            ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::SimpleSet>>,
         108  +
        pub(crate) complex_set:
         109  +
            ::std::option::Option<crate::constrained::MaybeConstrained<crate::model::ComplexSet>>,
         110  +
    }
         111  +
    impl Builder {
         112  +
        #[allow(missing_docs)] // documentation missing in model
         113  +
        pub fn set(mut self, input: ::std::option::Option<crate::model::SimpleSet>) -> Self {
         114  +
            self.set = input.map(crate::constrained::MaybeConstrained::Constrained);
         115  +
            self
         116  +
        }
         117  +
        #[allow(missing_docs)] // documentation missing in model
         118  +
        pub(crate) fn set_set(
         119  +
            mut self,
         120  +
            input: Option<
         121  +
                impl ::std::convert::Into<crate::constrained::MaybeConstrained<crate::model::SimpleSet>>,
         122  +
            >,
         123  +
        ) -> Self {
         124  +
            self.set = input.map(|v| v.into());
         125  +
            self
         126  +
        }
         127  +
        #[allow(missing_docs)] // documentation missing in model
         128  +
        pub fn complex_set(
         129  +
            mut self,
         130  +
            input: ::std::option::Option<crate::model::ComplexSet>,
         131  +
        ) -> Self {
         132  +
            self.complex_set = input.map(crate::constrained::MaybeConstrained::Constrained);
         133  +
            self
         134  +
        }
         135  +
        #[allow(missing_docs)] // documentation missing in model
         136  +
        pub(crate) fn set_complex_set(
         137  +
            mut self,
         138  +
            input: Option<
         139  +
                impl ::std::convert::Into<
         140  +
                    crate::constrained::MaybeConstrained<crate::model::ComplexSet>,
         141  +
                >,
         142  +
            >,
         143  +
        ) -> Self {
         144  +
            self.complex_set = input.map(|v| v.into());
         145  +
            self
         146  +
        }
         147  +
        /// Consumes the builder and constructs a [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput).
         148  +
        ///
         149  +
        /// The builder fails to construct a [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) if a [`ConstraintViolation`] occurs.
         150  +
        ///
         151  +
        /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         152  +
        pub fn build(self) -> Result<crate::input::MalformedUniqueItemsInput, ConstraintViolation> {
         153  +
            self.build_enforcing_all_constraints()
         154  +
        }
         155  +
        fn build_enforcing_all_constraints(
         156  +
            self,
         157  +
        ) -> Result<crate::input::MalformedUniqueItemsInput, ConstraintViolation> {
         158  +
            Ok(crate::input::MalformedUniqueItemsInput {
         159  +
                set: self
         160  +
                    .set
         161  +
                    .map(|v| match v {
         162  +
                        crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
         163  +
                        crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
         164  +
                    })
         165  +
                    .map(|res| res.map_err(ConstraintViolation::Set))
         166  +
                    .transpose()?,
         167  +
                complex_set: self
         168  +
                    .complex_set
         169  +
                    .map(|v| match v {
         170  +
                        crate::constrained::MaybeConstrained::Constrained(x) => Ok(x),
         171  +
                        crate::constrained::MaybeConstrained::Unconstrained(x) => x.try_into(),
         172  +
                    })
         173  +
                    .map(|res| res.map_err(ConstraintViolation::ComplexSet))
         174  +
                    .transpose()?,
         175  +
            })
         176  +
        }
         177  +
    }
         178  +
}

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

@@ -0,1 +0,251 @@
           1  +
#![allow(deprecated)]
           2  +
#![allow(unknown_lints)]
           3  +
#![allow(clippy::module_inception)]
           4  +
#![allow(clippy::upper_case_acronyms)]
           5  +
#![allow(clippy::large_enum_variant)]
           6  +
#![allow(clippy::wrong_self_convention)]
           7  +
#![allow(clippy::should_implement_trait)]
           8  +
#![allow(clippy::disallowed_names)]
           9  +
#![allow(clippy::vec_init_then_push)]
          10  +
#![allow(clippy::type_complexity)]
          11  +
#![allow(clippy::needless_return)]
          12  +
#![allow(clippy::derive_partial_eq_without_eq)]
          13  +
#![allow(clippy::result_large_err)]
          14  +
#![allow(clippy::unnecessary_map_on_constructor)]
          15  +
#![allow(clippy::deprecated_semver)]
          16  +
#![allow(clippy::uninlined_format_args)]
          17  +
#![allow(rustdoc::bare_urls)]
          18  +
#![allow(rustdoc::redundant_explicit_links)]
          19  +
#![allow(rustdoc::invalid_html_tags)]
          20  +
#![forbid(unsafe_code)]
          21  +
#![cfg_attr(docsrs, feature(doc_cfg))]
          22  +
//! unique_items-http0x
          23  +
          24  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
          25  +
//! A fast and customizable Rust implementation of the UniqueItemsService Smithy service.
          26  +
//!
          27  +
//! # Using UniqueItemsService
          28  +
//!
          29  +
//! The primary entrypoint is [`UniqueItemsService`]: it satisfies the [`Service<http::Request, Response = http::Response>`](::tower::Service)
          30  +
//! trait and therefore can be handed to a [`hyper` server](https://github.com/hyperium/hyper) via [`UniqueItemsService::into_make_service`]
          31  +
//! or used in AWS Lambda
          32  +
#![cfg_attr(
          33  +
    feature = "aws-lambda",
          34  +
    doc = " via [`LambdaHandler`](crate::server::routing::LambdaHandler)."
          35  +
)]
          36  +
#![cfg_attr(
          37  +
    not(feature = "aws-lambda"),
          38  +
    doc = " by enabling the `aws-lambda` feature flag and utilizing the `LambdaHandler`."
          39  +
)]
          40  +
//! The [`crate::input`], [`crate::output`], and [`crate::error`]
          41  +
//! modules provide the types used in each operation.
          42  +
//!
          43  +
//! ### Running on Hyper
          44  +
//!
          45  +
//! ```rust,no_run
          46  +
//! # use std::net::SocketAddr;
          47  +
//! # async fn dummy() {
          48  +
//! use unique_items_http0x::{UniqueItemsService, UniqueItemsServiceConfig};
          49  +
//!
          50  +
//! # let app = UniqueItemsService::builder(
          51  +
//! #     UniqueItemsServiceConfig::builder()
          52  +
//! #         .build()
          53  +
//! # ).build_unchecked();
          54  +
//! let server = app.into_make_service();
          55  +
//! let bind: SocketAddr = "127.0.0.1:6969".parse()
          56  +
//!     .expect("unable to parse the server bind address and port");
          57  +
//! ::hyper::Server::bind(&bind).serve(server).await.unwrap();
          58  +
//! # }
          59  +
//!
          60  +
//! ```
          61  +
//!
          62  +
//! ### Running on Lambda
          63  +
//!
          64  +
//! ```rust,ignore
          65  +
//! use unique_items_http0x::server::routing::LambdaHandler;
          66  +
//! use unique_items_http0x::UniqueItemsService;
          67  +
//!
          68  +
//! # async fn dummy() {
          69  +
//! # let app = UniqueItemsService::builder(
          70  +
//! #     UniqueItemsServiceConfig::builder()
          71  +
//! #         .build()
          72  +
//! # ).build_unchecked();
          73  +
//! let handler = LambdaHandler::new(app);
          74  +
//! lambda_http::run(handler).await.unwrap();
          75  +
//! # }
          76  +
//! ```
          77  +
//!
          78  +
//! # Building the UniqueItemsService
          79  +
//!
          80  +
//! To construct [`UniqueItemsService`] we use [`UniqueItemsServiceBuilder`] returned by [`UniqueItemsService::builder`].
          81  +
//!
          82  +
//! ## Plugins
          83  +
//!
          84  +
//! The [`UniqueItemsService::builder`] method, returning [`UniqueItemsServiceBuilder`],
          85  +
//! accepts a config object on which plugins can be registered.
          86  +
//! Plugins allow you to build middleware which is aware of the operation it is being applied to.
          87  +
//!
          88  +
//! ```rust,no_run
          89  +
//! # use unique_items_http0x::server::plugin::IdentityPlugin as LoggingPlugin;
          90  +
//! # use unique_items_http0x::server::plugin::IdentityPlugin as MetricsPlugin;
          91  +
//! # use ::hyper::Body;
          92  +
//! use unique_items_http0x::server::plugin::HttpPlugins;
          93  +
//! use unique_items_http0x::{UniqueItemsService, UniqueItemsServiceConfig, UniqueItemsServiceBuilder};
          94  +
//!
          95  +
//! let http_plugins = HttpPlugins::new()
          96  +
//!         .push(LoggingPlugin)
          97  +
//!         .push(MetricsPlugin);
          98  +
//! let config = UniqueItemsServiceConfig::builder().build();
          99  +
//! let builder: UniqueItemsServiceBuilder<::hyper::Body, _, _, _> = UniqueItemsService::builder(config);
         100  +
//! ```
         101  +
//!
         102  +
//! Check out [`crate::server::plugin`] to learn more about plugins.
         103  +
//!
         104  +
//! ## Handlers
         105  +
//!
         106  +
//! [`UniqueItemsServiceBuilder`] provides a setter method for each operation in your Smithy model. The setter methods expect an async function as input, matching the signature for the corresponding operation in your Smithy model.
         107  +
//! We call these async functions **handlers**. This is where your application business logic lives.
         108  +
//!
         109  +
//! Every handler must take an `Input`, and optional [`extractor arguments`](crate::server::request), while returning:
         110  +
//!
         111  +
//! * A `Result<Output, Error>` if your operation has modeled errors, or
         112  +
//! * An `Output` otherwise.
         113  +
//!
         114  +
//! ```rust,no_run
         115  +
//! # struct Input;
         116  +
//! # struct Output;
         117  +
//! # struct Error;
         118  +
//! async fn infallible_handler(input: Input) -> Output { todo!() }
         119  +
//!
         120  +
//! async fn fallible_handler(input: Input) -> Result<Output, Error> { todo!() }
         121  +
//! ```
         122  +
//!
         123  +
//! Handlers can accept up to 8 extractors:
         124  +
//!
         125  +
//! ```rust,no_run
         126  +
//! # struct Input;
         127  +
//! # struct Output;
         128  +
//! # struct Error;
         129  +
//! # struct State;
         130  +
//! # use std::net::SocketAddr;
         131  +
//! use unique_items_http0x::server::request::{extension::Extension, connect_info::ConnectInfo};
         132  +
//!
         133  +
//! async fn handler_with_no_extensions(input: Input) -> Output {
         134  +
//!     todo!()
         135  +
//! }
         136  +
//!
         137  +
//! async fn handler_with_one_extractor(input: Input, ext: Extension<State>) -> Output {
         138  +
//!     todo!()
         139  +
//! }
         140  +
//!
         141  +
//! async fn handler_with_two_extractors(
         142  +
//!     input: Input,
         143  +
//!     ext0: Extension<State>,
         144  +
//!     ext1: ConnectInfo<SocketAddr>,
         145  +
//! ) -> Output {
         146  +
//!     todo!()
         147  +
//! }
         148  +
//! ```
         149  +
//!
         150  +
//! See the [`operation module`](crate::operation) for information on precisely what constitutes a handler.
         151  +
//!
         152  +
//! ## Build
         153  +
//!
         154  +
//! You can convert [`UniqueItemsServiceBuilder`] into [`UniqueItemsService`] using either [`UniqueItemsServiceBuilder::build`] or [`UniqueItemsServiceBuilder::build_unchecked`].
         155  +
//!
         156  +
//! [`UniqueItemsServiceBuilder::build`] requires you to provide a handler for every single operation in your Smithy model. It will return an error if that is not the case.
         157  +
//!
         158  +
//! [`UniqueItemsServiceBuilder::build_unchecked`], instead, does not require exhaustiveness. The server will automatically return 500 Internal Server Error to all requests for operations that do not have a registered handler.
         159  +
//! [`UniqueItemsServiceBuilder::build_unchecked`] is particularly useful if you are deploying your Smithy service as a collection of Lambda functions, where each Lambda is only responsible for a subset of the operations in the Smithy service (or even a single one!).
         160  +
//!
         161  +
//! # Example
         162  +
//!
         163  +
//! ```rust,no_run
         164  +
//! # use std::net::SocketAddr;
         165  +
//! use unique_items_http0x::{UniqueItemsService, UniqueItemsServiceConfig};
         166  +
//!
         167  +
//! #[::tokio::main]
         168  +
//! pub async fn main() {
         169  +
//!    let config = UniqueItemsServiceConfig::builder().build();
         170  +
//!    let app = UniqueItemsService::builder(config)
         171  +
//!        .malformed_unique_items(malformed_unique_items)
         172  +
//!        .build()
         173  +
//!        .expect("failed to build an instance of UniqueItemsService");
         174  +
//!
         175  +
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
         176  +
//!        .expect("unable to parse the server bind address and port");
         177  +
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         178  +
//!    # let server = async { Ok::<_, ()>(()) };
         179  +
//!
         180  +
//!    // Run your service!
         181  +
//!    if let Err(err) = server.await {
         182  +
//!        eprintln!("server error: {:?}", err);
         183  +
//!    }
         184  +
//! }
         185  +
//!
         186  +
//! use unique_items_http0x::{input, output, error};
         187  +
//!
         188  +
//! async fn malformed_unique_items(input: input::MalformedUniqueItemsInput) -> Result<output::MalformedUniqueItemsOutput, error::MalformedUniqueItemsError> {
         189  +
//!     todo!()
         190  +
//! }
         191  +
//!
         192  +
//! ```
         193  +
//!
         194  +
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         195  +
//! [hyper server]: https://docs.rs/hyper/0.14.26/hyper/server/index.html
         196  +
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
         197  +
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
         198  +
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
         199  +
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         200  +
pub use crate::service::{
         201  +
    MissingOperationsError, UniqueItemsService, UniqueItemsServiceBuilder,
         202  +
    UniqueItemsServiceConfig, UniqueItemsServiceConfigBuilder,
         203  +
};
         204  +
         205  +
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         206  +
pub mod server {
         207  +
    // Re-export all types from the `aws-smithy-http-server` crate.
         208  +
    pub use ::aws_smithy_legacy_http_server::*;
         209  +
}
         210  +
         211  +
/// Crate version number.
         212  +
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
         213  +
         214  +
/// All error types that operations can return. Documentation on these types is copied from the model.
         215  +
pub mod error;
         216  +
         217  +
/// Input structures for operations. Documentation on these types is copied from the model.
         218  +
pub mod input;
         219  +
         220  +
/// Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
         221  +
pub mod model;
         222  +
         223  +
/// All operations that this crate can perform.
         224  +
pub mod operation;
         225  +
         226  +
/// A collection of types representing each operation defined in the service closure.
         227  +
///
         228  +
/// The [plugin system](::aws_smithy_legacy_http_server::plugin) makes use of these
         229  +
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
         230  +
/// parameterize [`Plugin`](::aws_smithy_legacy_http_server::plugin::Plugin) implementations. Their traits, such as
         231  +
/// [`OperationShape`](::aws_smithy_legacy_http_server::operation::OperationShape), can be used to provide
         232  +
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
         233  +
pub mod operation_shape;
         234  +
         235  +
/// Output structures for operations. Documentation on these types is copied from the model.
         236  +
pub mod output;
         237  +
         238  +
mod service;
         239  +
         240  +
/// Data primitives referenced by other data types.
         241  +
pub mod types;
         242  +
         243  +
/// Unconstrained types for constrained shapes.
         244  +
mod unconstrained;
         245  +
         246  +
/// Constrained types for constrained shapes.
         247  +
mod constrained;
         248  +
         249  +
mod mimes;
         250  +
         251  +
pub(crate) mod protocol_serde;

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

@@ -0,1 +0,7 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) static CONTENT_TYPE_APPLICATION_JSON: std::sync::LazyLock<::mime::Mime> =
           3  +
    std::sync::LazyLock::new(|| {
           4  +
        "application/json"
           5  +
            .parse::<::mime::Mime>()
           6  +
            .expect("BUG: MIME parsing failed, content_type is not valid")
           7  +
    });

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

@@ -0,1 +0,419 @@
           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.
           4  +
#[derive(
           5  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
           6  +
)]
           7  +
pub struct ValidationExceptionField {
           8  +
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
           9  +
    pub path: ::std::string::String,
          10  +
    /// A detailed description of the validation failure.
          11  +
    pub message: ::std::string::String,
          12  +
}
          13  +
impl ValidationExceptionField {
          14  +
    /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
          15  +
    pub fn path(&self) -> &str {
          16  +
        use std::ops::Deref;
          17  +
        self.path.deref()
          18  +
    }
          19  +
    /// A detailed description of the validation failure.
          20  +
    pub fn message(&self) -> &str {
          21  +
        use std::ops::Deref;
          22  +
        self.message.deref()
          23  +
    }
          24  +
}
          25  +
impl ValidationExceptionField {
          26  +
    /// Creates a new builder-style object to manufacture [`ValidationExceptionField`](crate::model::ValidationExceptionField).
          27  +
    pub fn builder() -> crate::model::validation_exception_field::Builder {
          28  +
        crate::model::validation_exception_field::Builder::default()
          29  +
    }
          30  +
}
          31  +
          32  +
#[allow(missing_docs)] // documentation missing in model
          33  +
///
          34  +
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
          35  +
/// [constraint traits]. Use [`ComplexSet::try_from`] to construct values of this type.
          36  +
///
          37  +
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
          38  +
///
          39  +
#[derive(
          40  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          41  +
)]
          42  +
pub struct ComplexSet(pub(crate) ::std::vec::Vec<crate::model::ComplexSetStruct>);
          43  +
impl ComplexSet {
          44  +
    /// Returns an immutable reference to the underlying [`::std::vec::Vec<crate::model::ComplexSetStruct>`].
          45  +
    pub fn inner(&self) -> &::std::vec::Vec<crate::model::ComplexSetStruct> {
          46  +
        &self.0
          47  +
    }
          48  +
    /// Consumes the value, returning the underlying [`::std::vec::Vec<crate::model::ComplexSetStruct>`].
          49  +
    pub fn into_inner(self) -> ::std::vec::Vec<crate::model::ComplexSetStruct> {
          50  +
        self.0
          51  +
    }
          52  +
          53  +
    fn check_unique_items(
          54  +
        items: ::std::vec::Vec<crate::model::ComplexSetStruct>,
          55  +
    ) -> ::std::result::Result<
          56  +
        ::std::vec::Vec<crate::model::ComplexSetStruct>,
          57  +
        crate::model::complex_set::ConstraintViolation,
          58  +
    > {
          59  +
        let mut seen = ::std::collections::HashMap::new();
          60  +
        let mut duplicate_indices = ::std::vec::Vec::new();
          61  +
        for (idx, item) in items.iter().enumerate() {
          62  +
            if let Some(prev_idx) = seen.insert(item, idx) {
          63  +
                duplicate_indices.push(prev_idx);
          64  +
            }
          65  +
        }
          66  +
          67  +
        let mut last_duplicate_indices = ::std::vec::Vec::new();
          68  +
        for idx in &duplicate_indices {
          69  +
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
          70  +
                last_duplicate_indices.push(prev_idx);
          71  +
            }
          72  +
        }
          73  +
        duplicate_indices.extend(last_duplicate_indices);
          74  +
          75  +
        if !duplicate_indices.is_empty() {
          76  +
            debug_assert!(duplicate_indices.len() >= 2);
          77  +
            Err(
          78  +
                crate::model::complex_set::ConstraintViolation::UniqueItems {
          79  +
                    duplicate_indices,
          80  +
                    original: items,
          81  +
                },
          82  +
            )
          83  +
        } else {
          84  +
            Ok(items)
          85  +
        }
          86  +
    }
          87  +
}
          88  +
impl ::std::convert::TryFrom<::std::vec::Vec<crate::model::ComplexSetStruct>> for ComplexSet {
          89  +
    type Error = crate::model::complex_set::ConstraintViolation;
          90  +
          91  +
    /// Constructs a `ComplexSet` from an [`::std::vec::Vec<crate::model::ComplexSetStruct>`], failing when the provided value does not satisfy the modeled constraints.
          92  +
    fn try_from(
          93  +
        value: ::std::vec::Vec<crate::model::ComplexSetStruct>,
          94  +
    ) -> ::std::result::Result<Self, Self::Error> {
          95  +
        let value = Self::check_unique_items(value)?;
          96  +
          97  +
        Ok(Self(value))
          98  +
    }
          99  +
}
         100  +
         101  +
impl ::std::convert::From<ComplexSet> for ::std::vec::Vec<crate::model::ComplexSetStruct> {
         102  +
    fn from(value: ComplexSet) -> Self {
         103  +
        value.into_inner()
         104  +
    }
         105  +
}
         106  +
impl crate::constrained::Constrained for ComplexSet {
         107  +
    type Unconstrained = crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained;
         108  +
}
         109  +
         110  +
#[allow(missing_docs)] // documentation missing in model
         111  +
#[derive(
         112  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         113  +
)]
         114  +
pub struct ComplexSetStruct {
         115  +
    #[allow(missing_docs)] // documentation missing in model
         116  +
    pub foo: ::std::option::Option<bool>,
         117  +
    #[allow(missing_docs)] // documentation missing in model
         118  +
    pub blob: ::std::option::Option<::aws_smithy_types::Blob>,
         119  +
}
         120  +
impl ComplexSetStruct {
         121  +
    #[allow(missing_docs)] // documentation missing in model
         122  +
    pub fn foo(&self) -> ::std::option::Option<bool> {
         123  +
        self.foo
         124  +
    }
         125  +
    #[allow(missing_docs)] // documentation missing in model
         126  +
    pub fn blob(&self) -> ::std::option::Option<&::aws_smithy_types::Blob> {
         127  +
        self.blob.as_ref()
         128  +
    }
         129  +
}
         130  +
impl ComplexSetStruct {
         131  +
    /// Creates a new builder-style object to manufacture [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         132  +
    pub fn builder() -> crate::model::complex_set_struct::Builder {
         133  +
        crate::model::complex_set_struct::Builder::default()
         134  +
    }
         135  +
}
         136  +
impl crate::constrained::Constrained for crate::model::ComplexSetStruct {
         137  +
    type Unconstrained = crate::model::complex_set_struct::Builder;
         138  +
}
         139  +
         140  +
#[allow(missing_docs)] // documentation missing in model
         141  +
///
         142  +
/// This is a constrained type because its corresponding modeled Smithy shape has one or more
         143  +
/// [constraint traits]. Use [`SimpleSet::try_from`] to construct values of this type.
         144  +
///
         145  +
/// [constraint traits]: https://smithy.io/2.0/spec/constraint-traits.html
         146  +
///
         147  +
#[derive(
         148  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         149  +
)]
         150  +
pub struct SimpleSet(pub(crate) ::std::vec::Vec<::std::string::String>);
         151  +
impl SimpleSet {
         152  +
    /// Returns an immutable reference to the underlying [`::std::vec::Vec<::std::string::String>`].
         153  +
    pub fn inner(&self) -> &::std::vec::Vec<::std::string::String> {
         154  +
        &self.0
         155  +
    }
         156  +
    /// Consumes the value, returning the underlying [`::std::vec::Vec<::std::string::String>`].
         157  +
    pub fn into_inner(self) -> ::std::vec::Vec<::std::string::String> {
         158  +
        self.0
         159  +
    }
         160  +
         161  +
    fn check_unique_items(
         162  +
        items: ::std::vec::Vec<::std::string::String>,
         163  +
    ) -> ::std::result::Result<
         164  +
        ::std::vec::Vec<::std::string::String>,
         165  +
        crate::model::simple_set::ConstraintViolation,
         166  +
    > {
         167  +
        let mut seen = ::std::collections::HashMap::new();
         168  +
        let mut duplicate_indices = ::std::vec::Vec::new();
         169  +
        for (idx, item) in items.iter().enumerate() {
         170  +
            if let Some(prev_idx) = seen.insert(item, idx) {
         171  +
                duplicate_indices.push(prev_idx);
         172  +
            }
         173  +
        }
         174  +
         175  +
        let mut last_duplicate_indices = ::std::vec::Vec::new();
         176  +
        for idx in &duplicate_indices {
         177  +
            if let Some(prev_idx) = seen.remove(&items[*idx]) {
         178  +
                last_duplicate_indices.push(prev_idx);
         179  +
            }
         180  +
        }
         181  +
        duplicate_indices.extend(last_duplicate_indices);
         182  +
         183  +
        if !duplicate_indices.is_empty() {
         184  +
            debug_assert!(duplicate_indices.len() >= 2);
         185  +
            Err(crate::model::simple_set::ConstraintViolation::UniqueItems {
         186  +
                duplicate_indices,
         187  +
                original: items,
         188  +
            })
         189  +
        } else {
         190  +
            Ok(items)
         191  +
        }
         192  +
    }
         193  +
}
         194  +
impl ::std::convert::TryFrom<::std::vec::Vec<::std::string::String>> for SimpleSet {
         195  +
    type Error = crate::model::simple_set::ConstraintViolation;
         196  +
         197  +
    /// Constructs a `SimpleSet` from an [`::std::vec::Vec<::std::string::String>`], failing when the provided value does not satisfy the modeled constraints.
         198  +
    fn try_from(
         199  +
        value: ::std::vec::Vec<::std::string::String>,
         200  +
    ) -> ::std::result::Result<Self, Self::Error> {
         201  +
        let value = Self::check_unique_items(value)?;
         202  +
         203  +
        Ok(Self(value))
         204  +
    }
         205  +
}
         206  +
         207  +
impl ::std::convert::From<SimpleSet> for ::std::vec::Vec<::std::string::String> {
         208  +
    fn from(value: SimpleSet) -> Self {
         209  +
        value.into_inner()
         210  +
    }
         211  +
}
         212  +
impl crate::constrained::Constrained for SimpleSet {
         213  +
    type Unconstrained = crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained;
         214  +
}
         215  +
         216  +
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         217  +
pub mod validation_exception_field {
         218  +
         219  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         220  +
    /// Holds one variant for each of the ways the builder can fail.
         221  +
    #[non_exhaustive]
         222  +
    #[allow(clippy::enum_variant_names)]
         223  +
    pub enum ConstraintViolation {
         224  +
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
         225  +
        MissingPath,
         226  +
        /// `message` was not provided but it is required when building `ValidationExceptionField`.
         227  +
        MissingMessage,
         228  +
    }
         229  +
    impl ::std::fmt::Display for ConstraintViolation {
         230  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         231  +
            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  +
            }
         235  +
        }
         236  +
    }
         237  +
    impl ::std::error::Error for ConstraintViolation {}
         238  +
    impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
         239  +
        type Error = ConstraintViolation;
         240  +
         241  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         242  +
            builder.build()
         243  +
        }
         244  +
    }
         245  +
    /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         246  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         247  +
    pub struct Builder {
         248  +
        pub(crate) path: ::std::option::Option<::std::string::String>,
         249  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         250  +
    }
         251  +
    impl Builder {
         252  +
        /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         253  +
        pub fn path(mut self, input: ::std::string::String) -> Self {
         254  +
            self.path = Some(input);
         255  +
            self
         256  +
        }
         257  +
        /// A detailed description of the validation failure.
         258  +
        pub fn message(mut self, input: ::std::string::String) -> Self {
         259  +
            self.message = Some(input);
         260  +
            self
         261  +
        }
         262  +
        /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         263  +
        ///
         264  +
        /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if a [`ConstraintViolation`] occurs.
         265  +
        ///
         266  +
        /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         267  +
        pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
         268  +
            self.build_enforcing_all_constraints()
         269  +
        }
         270  +
        fn build_enforcing_all_constraints(
         271  +
            self,
         272  +
        ) -> 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  +
            })
         277  +
        }
         278  +
    }
         279  +
}
         280  +
/// See [`ComplexSet`](crate::model::ComplexSet).
         281  +
pub mod complex_set {
         282  +
         283  +
    #[allow(clippy::enum_variant_names)]
         284  +
    #[derive(Debug, PartialEq)]
         285  +
    pub enum ConstraintViolation {
         286  +
        /// Constraint violation error when the list does not contain unique items
         287  +
        UniqueItems {
         288  +
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
         289  +
            /// at least two elements.
         290  +
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
         291  +
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
         292  +
            /// Nothing is guaranteed about the order of the indices.
         293  +
            duplicate_indices: ::std::vec::Vec<usize>,
         294  +
            /// The original vector, that contains duplicate items.
         295  +
            original: ::std::vec::Vec<crate::model::ComplexSetStruct>,
         296  +
        },
         297  +
    }
         298  +
         299  +
    impl ::std::fmt::Display for ConstraintViolation {
         300  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         301  +
            let message = match self {
         302  +
                                Self::UniqueItems { duplicate_indices, .. } =>
         303  +
                            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  +
                            };
         305  +
            write!(f, "{message}")
         306  +
        }
         307  +
    }
         308  +
         309  +
    impl ::std::error::Error for ConstraintViolation {}
         310  +
    impl ConstraintViolation {
         311  +
        pub(crate) fn as_validation_exception_field(
         312  +
            self,
         313  +
            path: ::std::string::String,
         314  +
        ) -> crate::model::ValidationExceptionField {
         315  +
            match self {
         316  +
                        Self::UniqueItems { duplicate_indices, .. } =>
         317  +
                                crate::model::ValidationExceptionField {
         318  +
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
         319  +
                                    path,
         320  +
                                },
         321  +
                    }
         322  +
        }
         323  +
    }
         324  +
}
         325  +
/// See [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         326  +
pub mod complex_set_struct {
         327  +
         328  +
    impl ::std::convert::From<Builder> for crate::model::ComplexSetStruct {
         329  +
        fn from(builder: Builder) -> Self {
         330  +
            builder.build()
         331  +
        }
         332  +
    }
         333  +
    /// A builder for [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         334  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         335  +
    pub struct Builder {
         336  +
        pub(crate) foo: ::std::option::Option<bool>,
         337  +
        pub(crate) blob: ::std::option::Option<::aws_smithy_types::Blob>,
         338  +
    }
         339  +
    impl Builder {
         340  +
        #[allow(missing_docs)] // documentation missing in model
         341  +
        pub fn foo(mut self, input: ::std::option::Option<bool>) -> Self {
         342  +
            self.foo = input;
         343  +
            self
         344  +
        }
         345  +
        #[allow(missing_docs)] // documentation missing in model
         346  +
        pub(crate) fn set_foo(mut self, input: Option<impl ::std::convert::Into<bool>>) -> Self {
         347  +
            self.foo = input.map(|v| v.into());
         348  +
            self
         349  +
        }
         350  +
        #[allow(missing_docs)] // documentation missing in model
         351  +
        pub fn blob(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
         352  +
            self.blob = input;
         353  +
            self
         354  +
        }
         355  +
        #[allow(missing_docs)] // documentation missing in model
         356  +
        pub(crate) fn set_blob(
         357  +
            mut self,
         358  +
            input: Option<impl ::std::convert::Into<::aws_smithy_types::Blob>>,
         359  +
        ) -> Self {
         360  +
            self.blob = input.map(|v| v.into());
         361  +
            self
         362  +
        }
         363  +
        /// Consumes the builder and constructs a [`ComplexSetStruct`](crate::model::ComplexSetStruct).
         364  +
        pub fn build(self) -> crate::model::ComplexSetStruct {
         365  +
            self.build_enforcing_all_constraints()
         366  +
        }
         367  +
        fn build_enforcing_all_constraints(self) -> crate::model::ComplexSetStruct {
         368  +
            crate::model::ComplexSetStruct {
         369  +
                foo: self.foo,
         370  +
                blob: self.blob,
         371  +
            }
         372  +
        }
         373  +
    }
         374  +
}
         375  +
/// See [`SimpleSet`](crate::model::SimpleSet).
         376  +
pub mod simple_set {
         377  +
         378  +
    #[allow(clippy::enum_variant_names)]
         379  +
    #[derive(Debug, PartialEq)]
         380  +
    pub enum ConstraintViolation {
         381  +
        /// Constraint violation error when the list does not contain unique items
         382  +
        UniqueItems {
         383  +
            /// A vector of indices into `original` pointing to all duplicate items. This vector has
         384  +
            /// at least two elements.
         385  +
            /// More specifically, for every element `idx_1` in `duplicate_indices`, there exists another
         386  +
            /// distinct element `idx_2` such that `original[idx_1] == original[idx_2]` is `true`.
         387  +
            /// Nothing is guaranteed about the order of the indices.
         388  +
            duplicate_indices: ::std::vec::Vec<usize>,
         389  +
            /// The original vector, that contains duplicate items.
         390  +
            original: ::std::vec::Vec<::std::string::String>,
         391  +
        },
         392  +
    }
         393  +
         394  +
    impl ::std::fmt::Display for ConstraintViolation {
         395  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         396  +
            let message = match self {
         397  +
                                Self::UniqueItems { duplicate_indices, .. } =>
         398  +
                            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  +
                            };
         400  +
            write!(f, "{message}")
         401  +
        }
         402  +
    }
         403  +
         404  +
    impl ::std::error::Error for ConstraintViolation {}
         405  +
    impl ConstraintViolation {
         406  +
        pub(crate) fn as_validation_exception_field(
         407  +
            self,
         408  +
            path: ::std::string::String,
         409  +
        ) -> crate::model::ValidationExceptionField {
         410  +
            match self {
         411  +
                        Self::UniqueItems { duplicate_indices, .. } =>
         412  +
                                crate::model::ValidationExceptionField {
         413  +
                                    message: format!("Value with repeated values at indices {:?} at '{}' failed to satisfy constraint: Member must have unique values", &duplicate_indices, &path),
         414  +
                                    path,
         415  +
                                },
         416  +
                    }
         417  +
        }
         418  +
    }
         419  +
}