Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9 (ignoring whitespace)

Files changed:

tmp-codegen-diff/codegen-server-test/naming_test_structs-http0x/rust-server-codegen/src/types.rs

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

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

@@ -1,1 +46,49 @@
   10     10   
codegen-version = "ci"
   11     11   
protocol = "aws.protocols#awsJson1_1"
   12     12   
[dependencies.aws-smithy-http]
   13     13   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http"
   14     14   
[dependencies.aws-smithy-http-server]
   15     15   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-http-server"
   16     16   
[dependencies.aws-smithy-json]
   17     17   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
   18     18   
[dependencies.aws-smithy-runtime-api]
   19     19   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
          20  +
features = ["http-1x"]
   20     21   
[dependencies.aws-smithy-types]
   21     22   
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
          23  +
features = ["http-body-1-x"]
   22     24   
[dependencies.futures-util]
   23     25   
version = "0.3"
   24         -
[dependencies.http]
   25         -
version = "0.2.9"
   26         -
[dependencies.hyper]
   27         -
version = "0.14.26"
          26  +
[dependencies.http-1x]
          27  +
version = "1"
          28  +
package = "http"
          29  +
[dependencies.http-body-util]
          30  +
version = "0.1.3"
   28     31   
[dependencies.mime]
   29     32   
version = "0.3"
   30     33   
[dependencies.pin-project-lite]
   31     34   
version = "0.2"
   32     35   
[dependencies.tower]
   33     36   
version = "0.4"
   34     37   
[dependencies.tracing]
   35     38   
version = "0.1"
   36     39   
[dev-dependencies.hyper]
   37         -
version = "0.14.12"
          40  +
version = "1"
   38     41   
[dev-dependencies.tokio]
   39     42   
version = "1.23.1"
   40     43   
[features]
   41     44   
rt-tokio = ["aws-smithy-types/rt-tokio"]
   42     45   
aws-lambda = ["aws-smithy-http-server/aws-lambda"]
   43     46   
request-id = ["aws-smithy-http-server/request-id"]
   44     47   
default = ["rt-tokio", "request-id"]
   45     48   
   46     49   

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

@@ -19,19 +128,131 @@
   39     39   
)]
   40     40   
//! The [`crate::input`], and [`crate::output`],
   41     41   
//! modules provide the types used in each operation.
   42     42   
//!
   43     43   
//! ### Running on Hyper
   44     44   
//!
   45     45   
//! ```rust,no_run
   46     46   
//! # use std::net::SocketAddr;
   47     47   
//! # async fn dummy() {
   48     48   
//! use naming_test_structs::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig};
          49  +
//! use naming_test_structs::serve;
          50  +
//! use ::tokio::net::TcpListener;
   49     51   
//!
   50     52   
//! # let app = NamingObstacleCourseStructs::builder(
   51     53   
//! #     NamingObstacleCourseStructsConfig::builder()
   52     54   
//! #         .build()
   53     55   
//! # ).build_unchecked();
   54         -
//! let server = app.into_make_service();
   55     56   
//! let bind: SocketAddr = "127.0.0.1:6969".parse()
   56     57   
//!     .expect("unable to parse the server bind address and port");
   57         -
//! ::hyper::Server::bind(&bind).serve(server).await.unwrap();
          58  +
//! let listener = TcpListener::bind(bind).await
          59  +
//!     .expect("failed to bind TCP listener");
          60  +
//! serve(listener, app.into_make_service()).await.unwrap();
   58     61   
//! # }
   59     62   
//! ```
   60     63   
//!
   61     64   
//! ### Running on Lambda
   62     65   
//!
   63     66   
//! ```rust,ignore
   64     67   
//! use naming_test_structs::server::routing::LambdaHandler;
   65     68   
//! use naming_test_structs::NamingObstacleCourseStructs;
   66     69   
//!
   67     70   
//! # async fn dummy() {
   68     71   
//! # let app = NamingObstacleCourseStructs::builder(
   69     72   
//! #     NamingObstacleCourseStructsConfig::builder()
   70     73   
//! #         .build()
   71     74   
//! # ).build_unchecked();
   72     75   
//! let handler = LambdaHandler::new(app);
   73     76   
//! lambda_http::run(handler).await.unwrap();
   74     77   
//! # }
   75     78   
//! ```
   76     79   
//!
   77     80   
//! # Building the NamingObstacleCourseStructs
   78     81   
//!
   79     82   
//! To construct [`NamingObstacleCourseStructs`] we use [`NamingObstacleCourseStructsBuilder`] returned by [`NamingObstacleCourseStructs::builder`].
   80     83   
//!
   81     84   
//! ## Plugins
   82     85   
//!
   83     86   
//! The [`NamingObstacleCourseStructs::builder`] method, returning [`NamingObstacleCourseStructsBuilder`],
   84     87   
//! accepts a config object on which plugins can be registered.
   85     88   
//! Plugins allow you to build middleware which is aware of the operation it is being applied to.
   86     89   
//!
   87     90   
//! ```rust,no_run
   88     91   
//! # use naming_test_structs::server::plugin::IdentityPlugin as LoggingPlugin;
   89     92   
//! # use naming_test_structs::server::plugin::IdentityPlugin as MetricsPlugin;
   90         -
//! # use ::hyper::Body;
          93  +
//! # use ::hyper::body::Incoming;
   91     94   
//! use naming_test_structs::server::plugin::HttpPlugins;
   92     95   
//! use naming_test_structs::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig, NamingObstacleCourseStructsBuilder};
   93     96   
//!
   94     97   
//! let http_plugins = HttpPlugins::new()
   95     98   
//!         .push(LoggingPlugin)
   96     99   
//!         .push(MetricsPlugin);
   97    100   
//! let config = NamingObstacleCourseStructsConfig::builder().build();
   98         -
//! let builder: NamingObstacleCourseStructsBuilder<Body, _, _, _> = NamingObstacleCourseStructs::builder(config);
         101  +
//! let builder: NamingObstacleCourseStructsBuilder<::hyper::body::Incoming, _, _, _> = NamingObstacleCourseStructs::builder(config);
   99    102   
//! ```
  100    103   
//!
  101    104   
//! Check out [`crate::server::plugin`] to learn more about plugins.
  102    105   
//!
  103    106   
//! ## Handlers
  104    107   
//!
  105    108   
//! [`NamingObstacleCourseStructsBuilder`] 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.
  106    109   
//! We call these async functions **handlers**. This is where your application business logic lives.
  107    110   
//!
  108    111   
//! Every handler must take an `Input`, and optional [`extractor arguments`](crate::server::request), while returning:
@@ -135,138 +228,235 @@
  155    158   
//! [`NamingObstacleCourseStructsBuilder::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.
  156    159   
//!
  157    160   
//! [`NamingObstacleCourseStructsBuilder::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.
  158    161   
//! [`NamingObstacleCourseStructsBuilder::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!).
  159    162   
//!
  160    163   
//! # Example
  161    164   
//!
  162    165   
//! ```rust,no_run
  163    166   
//! # use std::net::SocketAddr;
  164    167   
//! use naming_test_structs::{NamingObstacleCourseStructs, NamingObstacleCourseStructsConfig};
         168  +
//! use naming_test_structs::serve;
         169  +
//! use ::tokio::net::TcpListener;
  165    170   
//!
  166    171   
//! #[::tokio::main]
  167    172   
//! pub async fn main() {
  168    173   
//!    let config = NamingObstacleCourseStructsConfig::builder().build();
  169    174   
//!    let app = NamingObstacleCourseStructs::builder(config)
  170    175   
//!        .structs(structs)
  171    176   
//!        .build()
  172    177   
//!        .expect("failed to build an instance of NamingObstacleCourseStructs");
  173    178   
//!
  174    179   
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
  175    180   
//!        .expect("unable to parse the server bind address and port");
  176         -
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         181  +
//!    let listener = TcpListener::bind(bind).await
         182  +
//!        .expect("failed to bind TCP listener");
  177    183   
//!    # let server = async { Ok::<_, ()>(()) };
  178    184   
//!
  179    185   
//!    // Run your service!
  180         -
//!    if let Err(err) = server.await {
         186  +
//!    if let Err(err) = serve(listener, app.into_make_service()).await {
  181    187   
//!        eprintln!("server error: {:?}", err);
  182    188   
//!    }
  183    189   
//! }
  184    190   
//!
  185    191   
//! use naming_test_structs::{input, output};
  186    192   
//!
  187    193   
//! async fn structs(input: input::StructsInput) -> output::StructsOutput {
  188    194   
//!     todo!()
  189    195   
//! }
  190    196   
//!
  191    197   
//! ```
  192    198   
//!
  193         -
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         199  +
//! [`serve`]: crate::serve
         200  +
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  194    201   
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
  195    202   
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
  196    203   
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
  197         -
//! [hyper server]: https://docs.rs/hyper/latest/hyper/server/index.html
  198    204   
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         205  +
pub use crate::server::serve::serve;
  199    206   
pub use crate::service::{
  200    207   
    MissingOperationsError, NamingObstacleCourseStructs, NamingObstacleCourseStructsBuilder,
  201    208   
    NamingObstacleCourseStructsConfig, NamingObstacleCourseStructsConfigBuilder,
  202    209   
};
  203    210   
  204    211   
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
  205    212   
pub mod server {
  206    213   
    // Re-export all types from the `aws-smithy-http-server` crate.
  207    214   
    pub use ::aws_smithy_http_server::*;
  208    215   
}

tmp-codegen-diff/codegen-server-test/naming_test_structs/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::aws_json::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::aws_json::runtime_error::RuntimeError;
   39     39   
    type Future = StructsInputFuture;
   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_X_AMZ_JSON_1_1,
   46     46   
            ) {
   47     47   
                return Err(::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
   48     48   
            }
   49     49   
            crate::protocol_serde::shape_structs::de_structs_http_request(request).await
   50     50   
        };
   51     51   
        use ::futures_util::future::TryFutureExt;

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

@@ -1,1 +86,89 @@
    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_structs_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::StructsInput,
    7      7   
    ::aws_smithy_http_server::protocol::aws_json::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::aws_json::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::structs_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/x-amz-json-1.1"),
   27     30   
            )?;
   28     31   
            input = crate::protocol_serde::shape_structs::de_structs(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_structs_http_response(
   36     39   
    #[allow(unused_variables)] output: crate::output::StructsOutput,
   37     40   
) -> std::result::Result<
   38     41   
    ::aws_smithy_http_server::response::Response,
   39     42   
    ::aws_smithy_http_server::protocol::aws_json::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/x-amz-json-1.1",
   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_structs_output::ser_structs_output_output_output(&output)?;
   53     56   
        let content_length = payload.len();
   54     57   
        builder = ::aws_smithy_http::header::set_response_header_if_absent(
   55     58   
            builder,
   56         -
            ::http::header::CONTENT_LENGTH,
          59  +
            ::http_1x::header::CONTENT_LENGTH,
   57     60   
            content_length,
   58     61   
        );
   59     62   
        let body = ::aws_smithy_http_server::body::to_boxed(payload);
   60     63   
        builder.body(body)?
   61     64   
    })
   62     65   
}
   63     66   
   64     67   
pub(crate) fn de_structs(
   65     68   
    value: &[u8],
   66     69   
    mut builder: crate::input::structs_input::Builder,

tmp-codegen-diff/codegen-server-test/naming_test_structs/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   
                                    NamingObstacleCourseStructs<L>,
   59     59   
                                    crate::operation_shape::Structs,
   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::Structs::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.structs_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   
                                    NamingObstacleCourseStructs<L>,
  126    126   
                                    crate::operation_shape::Structs,
  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::Structs::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.structs_custom(svc)
  144    144   
    }
  145    145   
  146    146   
    /// Sets the [`Structs`](crate::operation_shape::Structs) to a custom [`Service`](tower::Service).
  147    147   
    /// not constrained by the Smithy contract.
  148    148   
    fn structs_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.structs = Some(::aws_smithy_http_server::routing::Route::new(svc));
  160    160   
        self
  161    161   
    }
  162    162   
}
@@ -393,393 +454,454 @@
  413    413   
    ) -> NamingObstacleCourseStructs<
  414    414   
        ::aws_smithy_http_server::routing::RoutingService<
  415    415   
            ::aws_smithy_http_server::protocol::aws_json::router::AwsJsonRouter<
  416    416   
                ::aws_smithy_http_server::routing::Route<B>,
  417    417   
            >,
  418    418   
            ::aws_smithy_http_server::protocol::aws_json_11::AwsJson1_1,
  419    419   
        >,
  420    420   
    >
  421    421   
    where
  422    422   
        S: ::tower::Service<
  423         -
            ::http::Request<B>,
  424         -
            Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
         423  +
            ::http_1x::Request<B>,
         424  +
            Response = ::http_1x::Response<::aws_smithy_http_server::body::BoxBody>,
  425    425   
            Error = std::convert::Infallible,
  426    426   
        >,
  427    427   
        S: Clone + Send + 'static,
  428    428   
        S::Future: Send + 'static,
  429    429   
    {
  430    430   
        self.layer(&::tower::layer::layer_fn(
  431    431   
            ::aws_smithy_http_server::routing::Route::new,
  432    432   
        ))
  433    433   
    }
  434    434   
}

tmp-codegen-diff/codegen-server-test/pokemon-service-awsjson-server-sdk-http0x/rust-server-codegen/Cargo.toml

@@ -0,1 +0,49 @@
           1  +
# Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
[package]
           3  +
name = "pokemon-service-awsjson-server-sdk-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#awsJson1_0"
          12  +
[dependencies.aws-smithy-eventstream]
          13  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-eventstream"
          14  +
[dependencies.aws-smithy-json]
          15  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-json"
          16  +
[dependencies.aws-smithy-legacy-http]
          17  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-legacy-http"
          18  +
features = ["event-stream"]
          19  +
[dependencies.aws-smithy-legacy-http-server]
          20  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-legacy-http-server"
          21  +
[dependencies.aws-smithy-runtime-api]
          22  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-runtime-api"
          23  +
features = ["http-02x"]
          24  +
[dependencies.aws-smithy-types]
          25  +
path = "/home/build/workspace/smithy-rs/rust-runtime/aws-smithy-types"
          26  +
features = ["http-body-0-4-x"]
          27  +
[dependencies.futures-util]
          28  +
version = "0.3"
          29  +
[dependencies.http]
          30  +
version = "0.2.9"
          31  +
[dependencies.mime]
          32  +
version = "0.3"
          33  +
[dependencies.pin-project-lite]
          34  +
version = "0.2"
          35  +
[dependencies.tower]
          36  +
version = "0.4"
          37  +
[dependencies.tracing]
          38  +
version = "0.1"
          39  +
[dev-dependencies.hyper]
          40  +
version = "0.14.26"
          41  +
[dev-dependencies.tokio]
          42  +
version = "1.23.1"
          43  +
[features]
          44  +
rt-tokio = ["aws-smithy-types/rt-tokio"]
          45  +
aws-lambda = ["aws-smithy-legacy-http-server/aws-lambda"]
          46  +
request-id = ["aws-smithy-legacy-http-server/request-id"]
          47  +
default = ["rt-tokio", "request-id"]
          48  +
          49  +

tmp-codegen-diff/codegen-server-test/pokemon-service-awsjson-server-sdk-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/pokemon-service-awsjson-server-sdk-http0x/rust-server-codegen/src/error.rs

@@ -0,1 +0,620 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
           3  +
/// Error type for the `CapturePokemon` operation.
           4  +
/// Each variant represents an error that can occur for the `CapturePokemon` operation.
           5  +
#[derive(::std::fmt::Debug)]
           6  +
pub enum CapturePokemonError {
           7  +
    #[allow(missing_docs)] // documentation missing in model
           8  +
    UnsupportedRegionError(crate::error::UnsupportedRegionError),
           9  +
    #[allow(missing_docs)] // documentation missing in model
          10  +
    ThrottlingError(crate::error::ThrottlingError),
          11  +
    /// 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.
          12  +
    ValidationException(crate::error::ValidationException),
          13  +
    #[allow(missing_docs)] // documentation missing in model
          14  +
    MasterBallUnsuccessful(crate::error::MasterBallUnsuccessful),
          15  +
    #[allow(missing_docs)] // documentation missing in model
          16  +
    InvalidPokeballError(crate::error::InvalidPokeballError),
          17  +
}
          18  +
impl ::std::fmt::Display for CapturePokemonError {
          19  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
          20  +
        match &self {
          21  +
            CapturePokemonError::UnsupportedRegionError(_inner) => _inner.fmt(f),
          22  +
            CapturePokemonError::ThrottlingError(_inner) => _inner.fmt(f),
          23  +
            CapturePokemonError::ValidationException(_inner) => _inner.fmt(f),
          24  +
            CapturePokemonError::MasterBallUnsuccessful(_inner) => _inner.fmt(f),
          25  +
            CapturePokemonError::InvalidPokeballError(_inner) => _inner.fmt(f),
          26  +
        }
          27  +
    }
          28  +
}
          29  +
impl CapturePokemonError {
          30  +
    /// Returns `true` if the error kind is `CapturePokemonError::UnsupportedRegionError`.
          31  +
    pub fn is_unsupported_region_error(&self) -> bool {
          32  +
        matches!(&self, CapturePokemonError::UnsupportedRegionError(_))
          33  +
    }
          34  +
    /// Returns `true` if the error kind is `CapturePokemonError::ThrottlingError`.
          35  +
    pub fn is_throttling_error(&self) -> bool {
          36  +
        matches!(&self, CapturePokemonError::ThrottlingError(_))
          37  +
    }
          38  +
    /// Returns `true` if the error kind is `CapturePokemonError::ValidationException`.
          39  +
    pub fn is_validation_exception(&self) -> bool {
          40  +
        matches!(&self, CapturePokemonError::ValidationException(_))
          41  +
    }
          42  +
    /// Returns `true` if the error kind is `CapturePokemonError::MasterBallUnsuccessful`.
          43  +
    pub fn is_master_ball_unsuccessful(&self) -> bool {
          44  +
        matches!(&self, CapturePokemonError::MasterBallUnsuccessful(_))
          45  +
    }
          46  +
    /// Returns `true` if the error kind is `CapturePokemonError::InvalidPokeballError`.
          47  +
    pub fn is_invalid_pokeball_error(&self) -> bool {
          48  +
        matches!(&self, CapturePokemonError::InvalidPokeballError(_))
          49  +
    }
          50  +
    /// Returns the error name string by matching the correct variant.
          51  +
    pub fn name(&self) -> &'static str {
          52  +
        match &self {
          53  +
            CapturePokemonError::UnsupportedRegionError(_inner) => _inner.name(),
          54  +
            CapturePokemonError::ThrottlingError(_inner) => _inner.name(),
          55  +
            CapturePokemonError::ValidationException(_inner) => _inner.name(),
          56  +
            CapturePokemonError::MasterBallUnsuccessful(_inner) => _inner.name(),
          57  +
            CapturePokemonError::InvalidPokeballError(_inner) => _inner.name(),
          58  +
        }
          59  +
    }
          60  +
}
          61  +
impl ::std::error::Error for CapturePokemonError {
          62  +
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
          63  +
        match &self {
          64  +
            CapturePokemonError::UnsupportedRegionError(_inner) => Some(_inner),
          65  +
            CapturePokemonError::ThrottlingError(_inner) => Some(_inner),
          66  +
            CapturePokemonError::ValidationException(_inner) => Some(_inner),
          67  +
            CapturePokemonError::MasterBallUnsuccessful(_inner) => Some(_inner),
          68  +
            CapturePokemonError::InvalidPokeballError(_inner) => Some(_inner),
          69  +
        }
          70  +
    }
          71  +
}
          72  +
impl ::std::convert::From<crate::error::UnsupportedRegionError>
          73  +
    for crate::error::CapturePokemonError
          74  +
{
          75  +
    fn from(variant: crate::error::UnsupportedRegionError) -> crate::error::CapturePokemonError {
          76  +
        Self::UnsupportedRegionError(variant)
          77  +
    }
          78  +
}
          79  +
impl ::std::convert::From<crate::error::ThrottlingError> for crate::error::CapturePokemonError {
          80  +
    fn from(variant: crate::error::ThrottlingError) -> crate::error::CapturePokemonError {
          81  +
        Self::ThrottlingError(variant)
          82  +
    }
          83  +
}
          84  +
impl ::std::convert::From<crate::error::ValidationException> for crate::error::CapturePokemonError {
          85  +
    fn from(variant: crate::error::ValidationException) -> crate::error::CapturePokemonError {
          86  +
        Self::ValidationException(variant)
          87  +
    }
          88  +
}
          89  +
impl ::std::convert::From<crate::error::MasterBallUnsuccessful>
          90  +
    for crate::error::CapturePokemonError
          91  +
{
          92  +
    fn from(variant: crate::error::MasterBallUnsuccessful) -> crate::error::CapturePokemonError {
          93  +
        Self::MasterBallUnsuccessful(variant)
          94  +
    }
          95  +
}
          96  +
impl ::std::convert::From<crate::error::InvalidPokeballError>
          97  +
    for crate::error::CapturePokemonError
          98  +
{
          99  +
    fn from(variant: crate::error::InvalidPokeballError) -> crate::error::CapturePokemonError {
         100  +
        Self::InvalidPokeballError(variant)
         101  +
    }
         102  +
}
         103  +
         104  +
#[allow(missing_docs)] // documentation missing in model
         105  +
#[derive(
         106  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         107  +
)]
         108  +
pub struct InvalidPokeballError {
         109  +
    #[allow(missing_docs)] // documentation missing in model
         110  +
    pub pokeball: ::std::string::String,
         111  +
}
         112  +
impl InvalidPokeballError {
         113  +
    #[allow(missing_docs)] // documentation missing in model
         114  +
    pub fn pokeball(&self) -> &str {
         115  +
        use std::ops::Deref;
         116  +
        self.pokeball.deref()
         117  +
    }
         118  +
}
         119  +
impl InvalidPokeballError {
         120  +
    #[doc(hidden)]
         121  +
    /// Returns the error name.
         122  +
    pub fn name(&self) -> &'static str {
         123  +
        "InvalidPokeballError"
         124  +
    }
         125  +
}
         126  +
impl ::std::fmt::Display for InvalidPokeballError {
         127  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         128  +
        ::std::write!(f, "InvalidPokeballError")?;
         129  +
        Ok(())
         130  +
    }
         131  +
}
         132  +
impl ::std::error::Error for InvalidPokeballError {}
         133  +
impl InvalidPokeballError {
         134  +
    /// Creates a new builder-style object to manufacture [`InvalidPokeballError`](crate::error::InvalidPokeballError).
         135  +
    pub fn builder() -> crate::error::invalid_pokeball_error::Builder {
         136  +
        crate::error::invalid_pokeball_error::Builder::default()
         137  +
    }
         138  +
}
         139  +
         140  +
#[allow(missing_docs)] // documentation missing in model
         141  +
#[derive(
         142  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         143  +
)]
         144  +
pub struct MasterBallUnsuccessful {
         145  +
    #[allow(missing_docs)] // documentation missing in model
         146  +
    pub message: ::std::option::Option<::std::string::String>,
         147  +
}
         148  +
impl MasterBallUnsuccessful {
         149  +
    /// Returns the error message.
         150  +
    pub fn message(&self) -> ::std::option::Option<&str> {
         151  +
        self.message.as_deref()
         152  +
    }
         153  +
    #[doc(hidden)]
         154  +
    /// Returns the error name.
         155  +
    pub fn name(&self) -> &'static str {
         156  +
        "MasterBallUnsuccessful"
         157  +
    }
         158  +
}
         159  +
impl ::std::fmt::Display for MasterBallUnsuccessful {
         160  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         161  +
        ::std::write!(f, "MasterBallUnsuccessful")?;
         162  +
        if let ::std::option::Option::Some(inner_1) = &self.message {
         163  +
            {
         164  +
                ::std::write!(f, ": {inner_1}")?;
         165  +
            }
         166  +
        }
         167  +
        Ok(())
         168  +
    }
         169  +
}
         170  +
impl ::std::error::Error for MasterBallUnsuccessful {}
         171  +
impl MasterBallUnsuccessful {
         172  +
    /// Creates a new builder-style object to manufacture [`MasterBallUnsuccessful`](crate::error::MasterBallUnsuccessful).
         173  +
    pub fn builder() -> crate::error::master_ball_unsuccessful::Builder {
         174  +
        crate::error::master_ball_unsuccessful::Builder::default()
         175  +
    }
         176  +
}
         177  +
impl crate::constrained::Constrained for crate::error::MasterBallUnsuccessful {
         178  +
    type Unconstrained = crate::error::master_ball_unsuccessful::Builder;
         179  +
}
         180  +
         181  +
/// 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.
         182  +
#[derive(
         183  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         184  +
)]
         185  +
pub struct ValidationException {
         186  +
    /// A summary of the validation failure.
         187  +
    pub message: ::std::string::String,
         188  +
    /// 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.
         189  +
    pub field_list: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         190  +
}
         191  +
impl ValidationException {
         192  +
    /// 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.
         193  +
    pub fn field_list(&self) -> ::std::option::Option<&[crate::model::ValidationExceptionField]> {
         194  +
        self.field_list.as_deref()
         195  +
    }
         196  +
}
         197  +
impl ValidationException {
         198  +
    /// Returns the error message.
         199  +
    pub fn message(&self) -> &str {
         200  +
        &self.message
         201  +
    }
         202  +
    #[doc(hidden)]
         203  +
    /// Returns the error name.
         204  +
    pub fn name(&self) -> &'static str {
         205  +
        "ValidationException"
         206  +
    }
         207  +
}
         208  +
impl ::std::fmt::Display for ValidationException {
         209  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         210  +
        ::std::write!(f, "ValidationException")?;
         211  +
        {
         212  +
            ::std::write!(f, ": {}", &self.message)?;
         213  +
        }
         214  +
        Ok(())
         215  +
    }
         216  +
}
         217  +
impl ::std::error::Error for ValidationException {}
         218  +
impl ValidationException {
         219  +
    /// Creates a new builder-style object to manufacture [`ValidationException`](crate::error::ValidationException).
         220  +
    pub fn builder() -> crate::error::validation_exception::Builder {
         221  +
        crate::error::validation_exception::Builder::default()
         222  +
    }
         223  +
}
         224  +
         225  +
#[allow(missing_docs)] // documentation missing in model
         226  +
#[derive(
         227  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         228  +
)]
         229  +
pub struct ThrottlingError {}
         230  +
impl ThrottlingError {
         231  +
    #[doc(hidden)]
         232  +
    /// Returns the error name.
         233  +
    pub fn name(&self) -> &'static str {
         234  +
        "ThrottlingError"
         235  +
    }
         236  +
}
         237  +
impl ::std::fmt::Display for ThrottlingError {
         238  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         239  +
        ::std::write!(f, "ThrottlingError")?;
         240  +
        Ok(())
         241  +
    }
         242  +
}
         243  +
impl ::std::error::Error for ThrottlingError {}
         244  +
impl ThrottlingError {
         245  +
    /// Creates a new builder-style object to manufacture [`ThrottlingError`](crate::error::ThrottlingError).
         246  +
    pub fn builder() -> crate::error::throttling_error::Builder {
         247  +
        crate::error::throttling_error::Builder::default()
         248  +
    }
         249  +
}
         250  +
         251  +
#[allow(missing_docs)] // documentation missing in model
         252  +
#[derive(
         253  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         254  +
)]
         255  +
pub struct UnsupportedRegionError {
         256  +
    #[allow(missing_docs)] // documentation missing in model
         257  +
    pub region: ::std::string::String,
         258  +
}
         259  +
impl UnsupportedRegionError {
         260  +
    #[allow(missing_docs)] // documentation missing in model
         261  +
    pub fn region(&self) -> &str {
         262  +
        use std::ops::Deref;
         263  +
        self.region.deref()
         264  +
    }
         265  +
}
         266  +
impl UnsupportedRegionError {
         267  +
    #[doc(hidden)]
         268  +
    /// Returns the error name.
         269  +
    pub fn name(&self) -> &'static str {
         270  +
        "UnsupportedRegionError"
         271  +
    }
         272  +
}
         273  +
impl ::std::fmt::Display for UnsupportedRegionError {
         274  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         275  +
        ::std::write!(f, "UnsupportedRegionError")?;
         276  +
        Ok(())
         277  +
    }
         278  +
}
         279  +
impl ::std::error::Error for UnsupportedRegionError {}
         280  +
impl UnsupportedRegionError {
         281  +
    /// Creates a new builder-style object to manufacture [`UnsupportedRegionError`](crate::error::UnsupportedRegionError).
         282  +
    pub fn builder() -> crate::error::unsupported_region_error::Builder {
         283  +
        crate::error::unsupported_region_error::Builder::default()
         284  +
    }
         285  +
}
         286  +
         287  +
/// Error type for the `CapturePokemonEvents` operation.
         288  +
/// Each variant represents an error that can occur for the `CapturePokemonEvents` operation.
         289  +
#[derive(::std::fmt::Debug)]
         290  +
pub enum CapturePokemonEventsError {
         291  +
    #[allow(missing_docs)] // documentation missing in model
         292  +
    InvalidPokeballError(crate::error::InvalidPokeballError),
         293  +
    #[allow(missing_docs)] // documentation missing in model
         294  +
    ThrottlingError(crate::error::ThrottlingError),
         295  +
}
         296  +
impl ::std::fmt::Display for CapturePokemonEventsError {
         297  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         298  +
        match &self {
         299  +
            CapturePokemonEventsError::InvalidPokeballError(_inner) => _inner.fmt(f),
         300  +
            CapturePokemonEventsError::ThrottlingError(_inner) => _inner.fmt(f),
         301  +
        }
         302  +
    }
         303  +
}
         304  +
impl CapturePokemonEventsError {
         305  +
    /// Returns `true` if the error kind is `CapturePokemonEventsError::InvalidPokeballError`.
         306  +
    pub fn is_invalid_pokeball_error(&self) -> bool {
         307  +
        matches!(&self, CapturePokemonEventsError::InvalidPokeballError(_))
         308  +
    }
         309  +
    /// Returns `true` if the error kind is `CapturePokemonEventsError::ThrottlingError`.
         310  +
    pub fn is_throttling_error(&self) -> bool {
         311  +
        matches!(&self, CapturePokemonEventsError::ThrottlingError(_))
         312  +
    }
         313  +
    /// Returns the error name string by matching the correct variant.
         314  +
    pub fn name(&self) -> &'static str {
         315  +
        match &self {
         316  +
            CapturePokemonEventsError::InvalidPokeballError(_inner) => _inner.name(),
         317  +
            CapturePokemonEventsError::ThrottlingError(_inner) => _inner.name(),
         318  +
        }
         319  +
    }
         320  +
}
         321  +
impl ::std::error::Error for CapturePokemonEventsError {
         322  +
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
         323  +
        match &self {
         324  +
            CapturePokemonEventsError::InvalidPokeballError(_inner) => Some(_inner),
         325  +
            CapturePokemonEventsError::ThrottlingError(_inner) => Some(_inner),
         326  +
        }
         327  +
    }
         328  +
}
         329  +
impl ::std::convert::From<crate::error::InvalidPokeballError>
         330  +
    for crate::error::CapturePokemonEventsError
         331  +
{
         332  +
    fn from(
         333  +
        variant: crate::error::InvalidPokeballError,
         334  +
    ) -> crate::error::CapturePokemonEventsError {
         335  +
        Self::InvalidPokeballError(variant)
         336  +
    }
         337  +
}
         338  +
impl ::std::convert::From<crate::error::ThrottlingError>
         339  +
    for crate::error::CapturePokemonEventsError
         340  +
{
         341  +
    fn from(variant: crate::error::ThrottlingError) -> crate::error::CapturePokemonEventsError {
         342  +
        Self::ThrottlingError(variant)
         343  +
    }
         344  +
}
         345  +
         346  +
/// Error type for the `AttemptCapturingPokemonEvent` operation.
         347  +
/// Each variant represents an error that can occur for the `AttemptCapturingPokemonEvent` operation.
         348  +
#[derive(::std::fmt::Debug)]
         349  +
pub enum AttemptCapturingPokemonEventError {
         350  +
    #[allow(missing_docs)] // documentation missing in model
         351  +
    MasterBallUnsuccessful(crate::error::MasterBallUnsuccessful),
         352  +
}
         353  +
impl ::std::fmt::Display for AttemptCapturingPokemonEventError {
         354  +
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         355  +
        match &self {
         356  +
            AttemptCapturingPokemonEventError::MasterBallUnsuccessful(_inner) => _inner.fmt(f),
         357  +
        }
         358  +
    }
         359  +
}
         360  +
impl AttemptCapturingPokemonEventError {
         361  +
    /// Returns `true` if the error kind is `AttemptCapturingPokemonEventError::MasterBallUnsuccessful`.
         362  +
    pub fn is_master_ball_unsuccessful(&self) -> bool {
         363  +
        matches!(
         364  +
            &self,
         365  +
            AttemptCapturingPokemonEventError::MasterBallUnsuccessful(_)
         366  +
        )
         367  +
    }
         368  +
    /// Returns the error name string by matching the correct variant.
         369  +
    pub fn name(&self) -> &'static str {
         370  +
        match &self {
         371  +
            AttemptCapturingPokemonEventError::MasterBallUnsuccessful(_inner) => _inner.name(),
         372  +
        }
         373  +
    }
         374  +
}
         375  +
impl ::std::error::Error for AttemptCapturingPokemonEventError {
         376  +
    fn source(&self) -> std::option::Option<&(dyn ::std::error::Error + 'static)> {
         377  +
        match &self {
         378  +
            AttemptCapturingPokemonEventError::MasterBallUnsuccessful(_inner) => Some(_inner),
         379  +
        }
         380  +
    }
         381  +
}
         382  +
impl ::std::convert::From<crate::error::MasterBallUnsuccessful>
         383  +
    for crate::error::AttemptCapturingPokemonEventError
         384  +
{
         385  +
    fn from(
         386  +
        variant: crate::error::MasterBallUnsuccessful,
         387  +
    ) -> crate::error::AttemptCapturingPokemonEventError {
         388  +
        Self::MasterBallUnsuccessful(variant)
         389  +
    }
         390  +
}
         391  +
         392  +
/// See [`InvalidPokeballError`](crate::error::InvalidPokeballError).
         393  +
pub mod invalid_pokeball_error {
         394  +
         395  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         396  +
    /// Holds one variant for each of the ways the builder can fail.
         397  +
    #[non_exhaustive]
         398  +
    #[allow(clippy::enum_variant_names)]
         399  +
    pub enum ConstraintViolation {
         400  +
        /// `pokeball` was not provided but it is required when building `InvalidPokeballError`.
         401  +
        MissingPokeball,
         402  +
    }
         403  +
    impl ::std::fmt::Display for ConstraintViolation {
         404  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         405  +
            match self {
         406  +
                ConstraintViolation::MissingPokeball => write!(f, "`pokeball` was not provided but it is required when building `InvalidPokeballError`"),
         407  +
            }
         408  +
        }
         409  +
    }
         410  +
    impl ::std::error::Error for ConstraintViolation {}
         411  +
    impl ::std::convert::TryFrom<Builder> for crate::error::InvalidPokeballError {
         412  +
        type Error = ConstraintViolation;
         413  +
         414  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         415  +
            builder.build()
         416  +
        }
         417  +
    }
         418  +
    /// A builder for [`InvalidPokeballError`](crate::error::InvalidPokeballError).
         419  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         420  +
    pub struct Builder {
         421  +
        pub(crate) pokeball: ::std::option::Option<::std::string::String>,
         422  +
    }
         423  +
    impl Builder {
         424  +
        #[allow(missing_docs)] // documentation missing in model
         425  +
        pub fn pokeball(mut self, input: ::std::string::String) -> Self {
         426  +
            self.pokeball = Some(input);
         427  +
            self
         428  +
        }
         429  +
        /// Consumes the builder and constructs a [`InvalidPokeballError`](crate::error::InvalidPokeballError).
         430  +
        ///
         431  +
        /// The builder fails to construct a [`InvalidPokeballError`](crate::error::InvalidPokeballError) if a [`ConstraintViolation`] occurs.
         432  +
        ///
         433  +
        pub fn build(self) -> Result<crate::error::InvalidPokeballError, ConstraintViolation> {
         434  +
            self.build_enforcing_all_constraints()
         435  +
        }
         436  +
        fn build_enforcing_all_constraints(
         437  +
            self,
         438  +
        ) -> Result<crate::error::InvalidPokeballError, ConstraintViolation> {
         439  +
            Ok(crate::error::InvalidPokeballError {
         440  +
                pokeball: self.pokeball.ok_or(ConstraintViolation::MissingPokeball)?,
         441  +
            })
         442  +
        }
         443  +
    }
         444  +
}
         445  +
/// See [`MasterBallUnsuccessful`](crate::error::MasterBallUnsuccessful).
         446  +
pub mod master_ball_unsuccessful {
         447  +
         448  +
    impl ::std::convert::From<Builder> for crate::error::MasterBallUnsuccessful {
         449  +
        fn from(builder: Builder) -> Self {
         450  +
            builder.build()
         451  +
        }
         452  +
    }
         453  +
    /// A builder for [`MasterBallUnsuccessful`](crate::error::MasterBallUnsuccessful).
         454  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         455  +
    pub struct Builder {
         456  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         457  +
    }
         458  +
    impl Builder {
         459  +
        #[allow(missing_docs)] // documentation missing in model
         460  +
        pub fn message(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         461  +
            self.message = input;
         462  +
            self
         463  +
        }
         464  +
        #[allow(missing_docs)] // documentation missing in model
         465  +
        pub(crate) fn set_message(
         466  +
            mut self,
         467  +
            input: Option<impl ::std::convert::Into<::std::string::String>>,
         468  +
        ) -> Self {
         469  +
            self.message = input.map(|v| v.into());
         470  +
            self
         471  +
        }
         472  +
        /// Consumes the builder and constructs a [`MasterBallUnsuccessful`](crate::error::MasterBallUnsuccessful).
         473  +
        pub fn build(self) -> crate::error::MasterBallUnsuccessful {
         474  +
            self.build_enforcing_all_constraints()
         475  +
        }
         476  +
        fn build_enforcing_all_constraints(self) -> crate::error::MasterBallUnsuccessful {
         477  +
            crate::error::MasterBallUnsuccessful {
         478  +
                message: self.message,
         479  +
            }
         480  +
        }
         481  +
    }
         482  +
}
         483  +
/// See [`ValidationException`](crate::error::ValidationException).
         484  +
pub mod validation_exception {
         485  +
         486  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         487  +
    /// Holds one variant for each of the ways the builder can fail.
         488  +
    #[non_exhaustive]
         489  +
    #[allow(clippy::enum_variant_names)]
         490  +
    pub enum ConstraintViolation {
         491  +
        /// `message` was not provided but it is required when building `ValidationException`.
         492  +
        MissingMessage,
         493  +
    }
         494  +
    impl ::std::fmt::Display for ConstraintViolation {
         495  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         496  +
            match self {
         497  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationException`"),
         498  +
            }
         499  +
        }
         500  +
    }
         501  +
    impl ::std::error::Error for ConstraintViolation {}
         502  +
    impl ::std::convert::TryFrom<Builder> for crate::error::ValidationException {
         503  +
        type Error = ConstraintViolation;
         504  +
         505  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         506  +
            builder.build()
         507  +
        }
         508  +
    }
         509  +
    /// A builder for [`ValidationException`](crate::error::ValidationException).
         510  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         511  +
    pub struct Builder {
         512  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         513  +
        pub(crate) field_list:
         514  +
            ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         515  +
    }
         516  +
    impl Builder {
         517  +
        /// A summary of the validation failure.
         518  +
        pub fn message(mut self, input: ::std::string::String) -> Self {
         519  +
            self.message = Some(input);
         520  +
            self
         521  +
        }
         522  +
        /// 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.
         523  +
        pub fn field_list(
         524  +
            mut self,
         525  +
            input: ::std::option::Option<::std::vec::Vec<crate::model::ValidationExceptionField>>,
         526  +
        ) -> Self {
         527  +
            self.field_list = input;
         528  +
            self
         529  +
        }
         530  +
        /// Consumes the builder and constructs a [`ValidationException`](crate::error::ValidationException).
         531  +
        ///
         532  +
        /// The builder fails to construct a [`ValidationException`](crate::error::ValidationException) if a [`ConstraintViolation`] occurs.
         533  +
        ///
         534  +
        pub fn build(self) -> Result<crate::error::ValidationException, ConstraintViolation> {
         535  +
            self.build_enforcing_all_constraints()
         536  +
        }
         537  +
        fn build_enforcing_all_constraints(
         538  +
            self,
         539  +
        ) -> Result<crate::error::ValidationException, ConstraintViolation> {
         540  +
            Ok(crate::error::ValidationException {
         541  +
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         542  +
                field_list: self.field_list,
         543  +
            })
         544  +
        }
         545  +
    }
         546  +
}
         547  +
/// See [`ThrottlingError`](crate::error::ThrottlingError).
         548  +
pub mod throttling_error {
         549  +
         550  +
    impl ::std::convert::From<Builder> for crate::error::ThrottlingError {
         551  +
        fn from(builder: Builder) -> Self {
         552  +
            builder.build()
         553  +
        }
         554  +
    }
         555  +
    /// A builder for [`ThrottlingError`](crate::error::ThrottlingError).
         556  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         557  +
    pub struct Builder {}
         558  +
    impl Builder {
         559  +
        /// Consumes the builder and constructs a [`ThrottlingError`](crate::error::ThrottlingError).
         560  +
        pub fn build(self) -> crate::error::ThrottlingError {
         561  +
            self.build_enforcing_all_constraints()
         562  +
        }
         563  +
        fn build_enforcing_all_constraints(self) -> crate::error::ThrottlingError {
         564  +
            crate::error::ThrottlingError {}
         565  +
        }
         566  +
    }
         567  +
}
         568  +
/// See [`UnsupportedRegionError`](crate::error::UnsupportedRegionError).
         569  +
pub mod unsupported_region_error {
         570  +
         571  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         572  +
    /// Holds one variant for each of the ways the builder can fail.
         573  +
    #[non_exhaustive]
         574  +
    #[allow(clippy::enum_variant_names)]
         575  +
    pub enum ConstraintViolation {
         576  +
        /// `region` was not provided but it is required when building `UnsupportedRegionError`.
         577  +
        MissingRegion,
         578  +
    }
         579  +
    impl ::std::fmt::Display for ConstraintViolation {
         580  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         581  +
            match self {
         582  +
                ConstraintViolation::MissingRegion => write!(f, "`region` was not provided but it is required when building `UnsupportedRegionError`"),
         583  +
            }
         584  +
        }
         585  +
    }
         586  +
    impl ::std::error::Error for ConstraintViolation {}
         587  +
    impl ::std::convert::TryFrom<Builder> for crate::error::UnsupportedRegionError {
         588  +
        type Error = ConstraintViolation;
         589  +
         590  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         591  +
            builder.build()
         592  +
        }
         593  +
    }
         594  +
    /// A builder for [`UnsupportedRegionError`](crate::error::UnsupportedRegionError).
         595  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         596  +
    pub struct Builder {
         597  +
        pub(crate) region: ::std::option::Option<::std::string::String>,
         598  +
    }
         599  +
    impl Builder {
         600  +
        #[allow(missing_docs)] // documentation missing in model
         601  +
        pub fn region(mut self, input: ::std::string::String) -> Self {
         602  +
            self.region = Some(input);
         603  +
            self
         604  +
        }
         605  +
        /// Consumes the builder and constructs a [`UnsupportedRegionError`](crate::error::UnsupportedRegionError).
         606  +
        ///
         607  +
        /// The builder fails to construct a [`UnsupportedRegionError`](crate::error::UnsupportedRegionError) if a [`ConstraintViolation`] occurs.
         608  +
        ///
         609  +
        pub fn build(self) -> Result<crate::error::UnsupportedRegionError, ConstraintViolation> {
         610  +
            self.build_enforcing_all_constraints()
         611  +
        }
         612  +
        fn build_enforcing_all_constraints(
         613  +
            self,
         614  +
        ) -> Result<crate::error::UnsupportedRegionError, ConstraintViolation> {
         615  +
            Ok(crate::error::UnsupportedRegionError {
         616  +
                region: self.region.ok_or(ConstraintViolation::MissingRegion)?,
         617  +
            })
         618  +
        }
         619  +
    }
         620  +
}

tmp-codegen-diff/codegen-server-test/pokemon-service-awsjson-server-sdk-http0x/rust-server-codegen/src/event_stream_serde.rs

@@ -0,1 +0,202 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[non_exhaustive]
           3  +
#[derive(Debug)]
           4  +
pub struct CapturePokemonEventsErrorMarshaller;
           5  +
           6  +
impl CapturePokemonEventsErrorMarshaller {
           7  +
    pub fn new() -> Self {
           8  +
        CapturePokemonEventsErrorMarshaller
           9  +
    }
          10  +
}
          11  +
impl ::aws_smithy_eventstream::frame::MarshallMessage for CapturePokemonEventsErrorMarshaller {
          12  +
    type Input = crate::error::CapturePokemonEventsError;
          13  +
    fn marshall(
          14  +
        &self,
          15  +
        _input: Self::Input,
          16  +
    ) -> std::result::Result<
          17  +
        ::aws_smithy_types::event_stream::Message,
          18  +
        ::aws_smithy_eventstream::error::Error,
          19  +
    > {
          20  +
        let mut headers = Vec::new();
          21  +
        headers.push(::aws_smithy_types::event_stream::Header::new(
          22  +
            ":message-type",
          23  +
            ::aws_smithy_types::event_stream::HeaderValue::String("exception".into()),
          24  +
        ));
          25  +
        let payload = match _input {
          26  +
            crate::error::CapturePokemonEventsError::InvalidPokeballError(inner) => {
          27  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
          28  +
                    ":exception-type",
          29  +
                    ::aws_smithy_types::event_stream::HeaderValue::String(
          30  +
                        "invalid_pokeball".into(),
          31  +
                    ),
          32  +
                ));
          33  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
          34  +
                    ":content-type",
          35  +
                    ::aws_smithy_types::event_stream::HeaderValue::String(
          36  +
                        "application/json".into(),
          37  +
                    ),
          38  +
                ));
          39  +
                crate::protocol_serde::shape_invalid_pokeball_error::ser_invalid_pokeball_error_error(&inner)
          40  +
                                            .map_err(|err| ::aws_smithy_eventstream::error::Error::marshalling(format!("{err}")))?
          41  +
            }
          42  +
            crate::error::CapturePokemonEventsError::ThrottlingError(inner) => {
          43  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
          44  +
                    ":exception-type",
          45  +
                    ::aws_smithy_types::event_stream::HeaderValue::String("throttlingError".into()),
          46  +
                ));
          47  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
          48  +
                    ":content-type",
          49  +
                    ::aws_smithy_types::event_stream::HeaderValue::String(
          50  +
                        "application/json".into(),
          51  +
                    ),
          52  +
                ));
          53  +
                crate::protocol_serde::shape_throttling_error::ser_throttling_error_error(&inner)
          54  +
                    .map_err(|err| {
          55  +
                        ::aws_smithy_eventstream::error::Error::marshalling(format!("{err}"))
          56  +
                    })?
          57  +
            }
          58  +
        };
          59  +
        Ok(::aws_smithy_types::event_stream::Message::new_from_parts(
          60  +
            headers, payload,
          61  +
        ))
          62  +
    }
          63  +
}
          64  +
          65  +
#[non_exhaustive]
          66  +
#[derive(Debug)]
          67  +
pub struct CapturePokemonEventsMarshaller;
          68  +
          69  +
impl CapturePokemonEventsMarshaller {
          70  +
    pub fn new() -> Self {
          71  +
        CapturePokemonEventsMarshaller
          72  +
    }
          73  +
}
          74  +
impl ::aws_smithy_eventstream::frame::MarshallMessage for CapturePokemonEventsMarshaller {
          75  +
    type Input = crate::model::CapturePokemonEvents;
          76  +
    fn marshall(
          77  +
        &self,
          78  +
        input: Self::Input,
          79  +
    ) -> std::result::Result<
          80  +
        ::aws_smithy_types::event_stream::Message,
          81  +
        ::aws_smithy_eventstream::error::Error,
          82  +
    > {
          83  +
        let mut headers = Vec::new();
          84  +
        headers.push(::aws_smithy_types::event_stream::Header::new(
          85  +
            ":message-type",
          86  +
            ::aws_smithy_types::event_stream::HeaderValue::String("event".into()),
          87  +
        ));
          88  +
        let payload = match input {
          89  +
            Self::Input::Event(inner) => {
          90  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
          91  +
                    ":event-type",
          92  +
                    ::aws_smithy_types::event_stream::HeaderValue::String("event".into()),
          93  +
                ));
          94  +
                if let Some(value) = inner.name {
          95  +
                    headers.push(::aws_smithy_types::event_stream::Header::new(
          96  +
                        "name",
          97  +
                        ::aws_smithy_types::event_stream::HeaderValue::String(value.into()),
          98  +
                    ));
          99  +
                }
         100  +
                if let Some(value) = inner.captured {
         101  +
                    headers.push(::aws_smithy_types::event_stream::Header::new(
         102  +
                        "captured",
         103  +
                        ::aws_smithy_types::event_stream::HeaderValue::Bool(value),
         104  +
                    ));
         105  +
                }
         106  +
                if let Some(value) = inner.shiny {
         107  +
                    headers.push(::aws_smithy_types::event_stream::Header::new(
         108  +
                        "shiny",
         109  +
                        ::aws_smithy_types::event_stream::HeaderValue::Bool(value),
         110  +
                    ));
         111  +
                }
         112  +
                headers.push(::aws_smithy_types::event_stream::Header::new(
         113  +
                    ":content-type",
         114  +
                    ::aws_smithy_types::event_stream::HeaderValue::String(
         115  +
                        "application/octet-stream".into(),
         116  +
                    ),
         117  +
                ));
         118  +
                if let Some(inner_payload) = inner.pokedex_update {
         119  +
                    inner_payload.into_inner()
         120  +
                } else {
         121  +
                    Vec::new()
         122  +
                }
         123  +
            }
         124  +
        };
         125  +
        Ok(::aws_smithy_types::event_stream::Message::new_from_parts(
         126  +
            headers, payload,
         127  +
        ))
         128  +
    }
         129  +
}
         130  +
         131  +
#[non_exhaustive]
         132  +
#[derive(Debug)]
         133  +
pub struct AttemptCapturingPokemonEventUnmarshaller;
         134  +
         135  +
impl AttemptCapturingPokemonEventUnmarshaller {
         136  +
    pub fn new() -> Self {
         137  +
        AttemptCapturingPokemonEventUnmarshaller
         138  +
    }
         139  +
}
         140  +
impl ::aws_smithy_eventstream::frame::UnmarshallMessage
         141  +
    for AttemptCapturingPokemonEventUnmarshaller
         142  +
{
         143  +
    type Output = crate::model::AttemptCapturingPokemonEvent;
         144  +
    type Error = crate::error::AttemptCapturingPokemonEventError;
         145  +
    fn unmarshall(
         146  +
        &self,
         147  +
        message: &::aws_smithy_types::event_stream::Message,
         148  +
    ) -> std::result::Result<
         149  +
        ::aws_smithy_eventstream::frame::UnmarshalledMessage<Self::Output, Self::Error>,
         150  +
        ::aws_smithy_eventstream::error::Error,
         151  +
    > {
         152  +
        let response_headers = ::aws_smithy_eventstream::smithy::parse_response_headers(message)?;
         153  +
        match response_headers.message_type.as_str() {
         154  +
            "event" => match response_headers.smithy_type.as_str() {
         155  +
                "event" => {
         156  +
                    let mut builder = crate::model::capturing_event::Builder::default();
         157  +
                    builder = builder.set_payload(
         158  +
                            Some(
         159  +
                                crate::protocol_serde::shape_capturing_payload::de_capturing_payload_payload(&message.payload()[..])
         160  +
                                                .map_err(|err| {
         161  +
                                                    ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall payload: {err}"))
         162  +
                                                })?
         163  +
                            )
         164  +
                        );
         165  +
                    Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Event(
         166  +
                        crate::model::AttemptCapturingPokemonEvent::Event(builder.build()),
         167  +
                    ))
         168  +
                }
         169  +
                _unknown_variant => {
         170  +
                    return Err(::aws_smithy_eventstream::error::Error::unmarshalling(
         171  +
                        format!("unrecognized :event-type: {_unknown_variant}"),
         172  +
                    ));
         173  +
                }
         174  +
            },
         175  +
            "exception" => {
         176  +
                if response_headers.smithy_type.as_str() == "masterball_unsuccessful" {
         177  +
                    let mut builder = crate::error::master_ball_unsuccessful::Builder::default();
         178  +
                    builder = crate::protocol_serde::shape_master_ball_unsuccessful::de_master_ball_unsuccessful_json_err(&message.payload()[..], builder)
         179  +
                                                            .map_err(|err| {
         180  +
                                                                ::aws_smithy_eventstream::error::Error::unmarshalling(format!("failed to unmarshall masterball_unsuccessful: {err}"))
         181  +
                                                            })?;
         182  +
                    return Ok(::aws_smithy_eventstream::frame::UnmarshalledMessage::Error(
         183  +
                        crate::error::AttemptCapturingPokemonEventError::MasterBallUnsuccessful(
         184  +
                            builder.build(),
         185  +
                        ),
         186  +
                    ));
         187  +
                }
         188  +
                return Err(aws_smithy_eventstream::error::Error::unmarshalling(
         189  +
                    format!(
         190  +
                        "unrecognized exception: {}",
         191  +
                        response_headers.smithy_type.as_str()
         192  +
                    ),
         193  +
                ));
         194  +
            }
         195  +
            value => {
         196  +
                return Err(::aws_smithy_eventstream::error::Error::unmarshalling(
         197  +
                    format!("unrecognized :message-type: {value}"),
         198  +
                ));
         199  +
            }
         200  +
        }
         201  +
    }
         202  +
}

tmp-codegen-diff/codegen-server-test/pokemon-service-awsjson-server-sdk-http0x/rust-server-codegen/src/input.rs

@@ -0,1 +0,254 @@
           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 CheckHealthInput {}
           7  +
impl CheckHealthInput {
           8  +
    /// Creates a new builder-style object to manufacture [`CheckHealthInput`](crate::input::CheckHealthInput).
           9  +
    pub fn builder() -> crate::input::check_health_input::Builder {
          10  +
        crate::input::check_health_input::Builder::default()
          11  +
    }
          12  +
}
          13  +
impl crate::constrained::Constrained for crate::input::CheckHealthInput {
          14  +
    type Unconstrained = crate::input::check_health_input::Builder;
          15  +
}
          16  +
          17  +
#[allow(missing_docs)] // documentation missing in model
          18  +
#[derive(::std::fmt::Debug)]
          19  +
pub struct CapturePokemonInput {
          20  +
    #[allow(missing_docs)] // documentation missing in model
          21  +
    pub events: ::aws_smithy_legacy_http::event_stream::Receiver<
          22  +
        crate::model::AttemptCapturingPokemonEvent,
          23  +
        crate::error::AttemptCapturingPokemonEventError,
          24  +
    >,
          25  +
}
          26  +
impl CapturePokemonInput {
          27  +
    #[allow(missing_docs)] // documentation missing in model
          28  +
    pub fn events(
          29  +
        &self,
          30  +
    ) -> &::aws_smithy_legacy_http::event_stream::Receiver<
          31  +
        crate::model::AttemptCapturingPokemonEvent,
          32  +
        crate::error::AttemptCapturingPokemonEventError,
          33  +
    > {
          34  +
        &self.events
          35  +
    }
          36  +
}
          37  +
impl CapturePokemonInput {
          38  +
    /// Creates a new builder-style object to manufacture [`CapturePokemonInput`](crate::input::CapturePokemonInput).
          39  +
    pub fn builder() -> crate::input::capture_pokemon_input::Builder {
          40  +
        crate::input::capture_pokemon_input::Builder::default()
          41  +
    }
          42  +
}
          43  +
impl crate::constrained::Constrained for crate::input::CapturePokemonInput {
          44  +
    type Unconstrained = crate::input::capture_pokemon_input::Builder;
          45  +
}
          46  +
          47  +
#[allow(missing_docs)] // documentation missing in model
          48  +
#[derive(
          49  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          50  +
)]
          51  +
pub struct DoNothingInput {}
          52  +
impl DoNothingInput {
          53  +
    /// Creates a new builder-style object to manufacture [`DoNothingInput`](crate::input::DoNothingInput).
          54  +
    pub fn builder() -> crate::input::do_nothing_input::Builder {
          55  +
        crate::input::do_nothing_input::Builder::default()
          56  +
    }
          57  +
}
          58  +
impl crate::constrained::Constrained for crate::input::DoNothingInput {
          59  +
    type Unconstrained = crate::input::do_nothing_input::Builder;
          60  +
}
          61  +
          62  +
#[allow(missing_docs)] // documentation missing in model
          63  +
#[derive(
          64  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          65  +
)]
          66  +
pub struct GetServerStatisticsInput {}
          67  +
impl GetServerStatisticsInput {
          68  +
    /// Creates a new builder-style object to manufacture [`GetServerStatisticsInput`](crate::input::GetServerStatisticsInput).
          69  +
    pub fn builder() -> crate::input::get_server_statistics_input::Builder {
          70  +
        crate::input::get_server_statistics_input::Builder::default()
          71  +
    }
          72  +
}
          73  +
impl crate::constrained::Constrained for crate::input::GetServerStatisticsInput {
          74  +
    type Unconstrained = crate::input::get_server_statistics_input::Builder;
          75  +
}
          76  +
/// See [`CheckHealthInput`](crate::input::CheckHealthInput).
          77  +
pub mod check_health_input {
          78  +
          79  +
    impl ::std::convert::From<Builder> for crate::input::CheckHealthInput {
          80  +
        fn from(builder: Builder) -> Self {
          81  +
            builder.build()
          82  +
        }
          83  +
    }
          84  +
    /// A builder for [`CheckHealthInput`](crate::input::CheckHealthInput).
          85  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
          86  +
    pub struct Builder {}
          87  +
    impl Builder {
          88  +
        /// Consumes the builder and constructs a [`CheckHealthInput`](crate::input::CheckHealthInput).
          89  +
        pub fn build(self) -> crate::input::CheckHealthInput {
          90  +
            self.build_enforcing_all_constraints()
          91  +
        }
          92  +
        fn build_enforcing_all_constraints(self) -> crate::input::CheckHealthInput {
          93  +
            crate::input::CheckHealthInput {}
          94  +
        }
          95  +
    }
          96  +
}
          97  +
/// See [`CapturePokemonInput`](crate::input::CapturePokemonInput).
          98  +
pub mod capture_pokemon_input {
          99  +
         100  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         101  +
    /// Holds one variant for each of the ways the builder can fail.
         102  +
    #[non_exhaustive]
         103  +
    #[allow(clippy::enum_variant_names)]
         104  +
    pub enum ConstraintViolation {
         105  +
        /// `events` was not provided but it is required when building `CapturePokemonInput`.
         106  +
        MissingEvents,
         107  +
    }
         108  +
    impl ::std::fmt::Display for ConstraintViolation {
         109  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         110  +
            match self {
         111  +
                ConstraintViolation::MissingEvents => write!(f, "`events` was not provided but it is required when building `CapturePokemonInput`"),
         112  +
            }
         113  +
        }
         114  +
    }
         115  +
    impl ::std::error::Error for ConstraintViolation {}
         116  +
    impl ConstraintViolation {
         117  +
        pub(crate) fn as_validation_exception_field(
         118  +
            self,
         119  +
            path: ::std::string::String,
         120  +
        ) -> crate::model::ValidationExceptionField {
         121  +
            match self {
         122  +
            ConstraintViolation::MissingEvents => crate::model::ValidationExceptionField {
         123  +
                                                message: format!("Value at '{}/events' failed to satisfy constraint: Member must not be null", path),
         124  +
                                                path: path + "/events",
         125  +
                                            },
         126  +
        }
         127  +
        }
         128  +
    }
         129  +
    impl ::std::convert::From<ConstraintViolation>
         130  +
        for ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection
         131  +
    {
         132  +
        fn from(constraint_violation: ConstraintViolation) -> Self {
         133  +
            let first_validation_exception_field =
         134  +
                constraint_violation.as_validation_exception_field("".to_owned());
         135  +
            let validation_exception = crate::error::ValidationException {
         136  +
                message: format!(
         137  +
                    "1 validation error detected. {}",
         138  +
                    &first_validation_exception_field.message
         139  +
                ),
         140  +
                field_list: Some(vec![first_validation_exception_field]),
         141  +
            };
         142  +
            Self::ConstraintViolation(
         143  +
                                crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(&validation_exception)
         144  +
                                    .expect("validation exceptions should never fail to serialize; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues")
         145  +
                            )
         146  +
        }
         147  +
    }
         148  +
    impl ::std::convert::From<Builder>
         149  +
        for crate::constrained::MaybeConstrained<crate::input::CapturePokemonInput>
         150  +
    {
         151  +
        fn from(builder: Builder) -> Self {
         152  +
            Self::Unconstrained(builder)
         153  +
        }
         154  +
    }
         155  +
    impl ::std::convert::TryFrom<Builder> for crate::input::CapturePokemonInput {
         156  +
        type Error = ConstraintViolation;
         157  +
         158  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         159  +
            builder.build()
         160  +
        }
         161  +
    }
         162  +
    /// A builder for [`CapturePokemonInput`](crate::input::CapturePokemonInput).
         163  +
    #[derive(::std::default::Default, ::std::fmt::Debug)]
         164  +
    pub struct Builder {
         165  +
        pub(crate) events: ::std::option::Option<
         166  +
            ::aws_smithy_legacy_http::event_stream::Receiver<
         167  +
                crate::model::AttemptCapturingPokemonEvent,
         168  +
                crate::error::AttemptCapturingPokemonEventError,
         169  +
            >,
         170  +
        >,
         171  +
    }
         172  +
    impl Builder {
         173  +
        #[allow(missing_docs)] // documentation missing in model
         174  +
        pub fn events(
         175  +
            mut self,
         176  +
            input: ::aws_smithy_legacy_http::event_stream::Receiver<
         177  +
                crate::model::AttemptCapturingPokemonEvent,
         178  +
                crate::error::AttemptCapturingPokemonEventError,
         179  +
            >,
         180  +
        ) -> Self {
         181  +
            self.events = Some(input);
         182  +
            self
         183  +
        }
         184  +
        #[allow(missing_docs)] // documentation missing in model
         185  +
        pub(crate) fn set_events(
         186  +
            mut self,
         187  +
            input: impl ::std::convert::Into<
         188  +
                ::aws_smithy_legacy_http::event_stream::Receiver<
         189  +
                    crate::model::AttemptCapturingPokemonEvent,
         190  +
                    crate::error::AttemptCapturingPokemonEventError,
         191  +
                >,
         192  +
            >,
         193  +
        ) -> Self {
         194  +
            self.events = Some(input.into());
         195  +
            self
         196  +
        }
         197  +
        /// Consumes the builder and constructs a [`CapturePokemonInput`](crate::input::CapturePokemonInput).
         198  +
        ///
         199  +
        /// The builder fails to construct a [`CapturePokemonInput`](crate::input::CapturePokemonInput) if a [`ConstraintViolation`] occurs.
         200  +
        ///
         201  +
        pub fn build(self) -> Result<crate::input::CapturePokemonInput, ConstraintViolation> {
         202  +
            self.build_enforcing_all_constraints()
         203  +
        }
         204  +
        fn build_enforcing_all_constraints(
         205  +
            self,
         206  +
        ) -> Result<crate::input::CapturePokemonInput, ConstraintViolation> {
         207  +
            Ok(crate::input::CapturePokemonInput {
         208  +
                events: self.events.ok_or(ConstraintViolation::MissingEvents)?,
         209  +
            })
         210  +
        }
         211  +
    }
         212  +
}
         213  +
/// See [`DoNothingInput`](crate::input::DoNothingInput).
         214  +
pub mod do_nothing_input {
         215  +
         216  +
    impl ::std::convert::From<Builder> for crate::input::DoNothingInput {
         217  +
        fn from(builder: Builder) -> Self {
         218  +
            builder.build()
         219  +
        }
         220  +
    }
         221  +
    /// A builder for [`DoNothingInput`](crate::input::DoNothingInput).
         222  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         223  +
    pub struct Builder {}
         224  +
    impl Builder {
         225  +
        /// Consumes the builder and constructs a [`DoNothingInput`](crate::input::DoNothingInput).
         226  +
        pub fn build(self) -> crate::input::DoNothingInput {
         227  +
            self.build_enforcing_all_constraints()
         228  +
        }
         229  +
        fn build_enforcing_all_constraints(self) -> crate::input::DoNothingInput {
         230  +
            crate::input::DoNothingInput {}
         231  +
        }
         232  +
    }
         233  +
}
         234  +
/// See [`GetServerStatisticsInput`](crate::input::GetServerStatisticsInput).
         235  +
pub mod get_server_statistics_input {
         236  +
         237  +
    impl ::std::convert::From<Builder> for crate::input::GetServerStatisticsInput {
         238  +
        fn from(builder: Builder) -> Self {
         239  +
            builder.build()
         240  +
        }
         241  +
    }
         242  +
    /// A builder for [`GetServerStatisticsInput`](crate::input::GetServerStatisticsInput).
         243  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         244  +
    pub struct Builder {}
         245  +
    impl Builder {
         246  +
        /// Consumes the builder and constructs a [`GetServerStatisticsInput`](crate::input::GetServerStatisticsInput).
         247  +
        pub fn build(self) -> crate::input::GetServerStatisticsInput {
         248  +
            self.build_enforcing_all_constraints()
         249  +
        }
         250  +
        fn build_enforcing_all_constraints(self) -> crate::input::GetServerStatisticsInput {
         251  +
            crate::input::GetServerStatisticsInput {}
         252  +
        }
         253  +
    }
         254  +
}