Server Test

Server Test

rev. ee474c7509d7728618c23068f3741e8e5b339ef9

Files changed:

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

@@ -0,1 +0,265 @@
           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  +
//! The Pokémon Service allows you to retrieve information about Pokémon species.
          23  +
          24  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
          25  +
//! A fast and customizable Rust implementation of the PokemonService Smithy service.
          26  +
//!
          27  +
//! # Using PokemonService
          28  +
//!
          29  +
//! The primary entrypoint is [`PokemonService`]: 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 [`PokemonService::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 pokemon_service_awsjson_server_sdk_http0x::{PokemonService, PokemonServiceConfig};
          49  +
//!
          50  +
//! # let app = PokemonService::builder(
          51  +
//! #     PokemonServiceConfig::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 pokemon_service_awsjson_server_sdk_http0x::server::routing::LambdaHandler;
          66  +
//! use pokemon_service_awsjson_server_sdk_http0x::PokemonService;
          67  +
//!
          68  +
//! # async fn dummy() {
          69  +
//! # let app = PokemonService::builder(
          70  +
//! #     PokemonServiceConfig::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 PokemonService
          79  +
//!
          80  +
//! To construct [`PokemonService`] we use [`PokemonServiceBuilder`] returned by [`PokemonService::builder`].
          81  +
//!
          82  +
//! ## Plugins
          83  +
//!
          84  +
//! The [`PokemonService::builder`] method, returning [`PokemonServiceBuilder`],
          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 pokemon_service_awsjson_server_sdk_http0x::server::plugin::IdentityPlugin as LoggingPlugin;
          90  +
//! # use pokemon_service_awsjson_server_sdk_http0x::server::plugin::IdentityPlugin as MetricsPlugin;
          91  +
//! # use ::hyper::Body;
          92  +
//! use pokemon_service_awsjson_server_sdk_http0x::server::plugin::HttpPlugins;
          93  +
//! use pokemon_service_awsjson_server_sdk_http0x::{PokemonService, PokemonServiceConfig, PokemonServiceBuilder};
          94  +
//!
          95  +
//! let http_plugins = HttpPlugins::new()
          96  +
//!         .push(LoggingPlugin)
          97  +
//!         .push(MetricsPlugin);
          98  +
//! let config = PokemonServiceConfig::builder().build();
          99  +
//! let builder: PokemonServiceBuilder<::hyper::Body, _, _, _> = PokemonService::builder(config);
         100  +
//! ```
         101  +
//!
         102  +
//! Check out [`crate::server::plugin`] to learn more about plugins.
         103  +
//!
         104  +
//! ## Handlers
         105  +
//!
         106  +
//! [`PokemonServiceBuilder`] 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 pokemon_service_awsjson_server_sdk_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 [`PokemonServiceBuilder`] into [`PokemonService`] using either [`PokemonServiceBuilder::build`] or [`PokemonServiceBuilder::build_unchecked`].
         155  +
//!
         156  +
//! [`PokemonServiceBuilder::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  +
//! [`PokemonServiceBuilder::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  +
//! [`PokemonServiceBuilder::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 pokemon_service_awsjson_server_sdk_http0x::{PokemonService, PokemonServiceConfig};
         166  +
//!
         167  +
//! #[::tokio::main]
         168  +
//! pub async fn main() {
         169  +
//!    let config = PokemonServiceConfig::builder().build();
         170  +
//!    let app = PokemonService::builder(config)
         171  +
//!        .capture_pokemon(capture_pokemon)
         172  +
//!        .check_health(check_health)
         173  +
//!        .do_nothing(do_nothing)
         174  +
//!        .get_server_statistics(get_server_statistics)
         175  +
//!        .build()
         176  +
//!        .expect("failed to build an instance of PokemonService");
         177  +
//!
         178  +
//!    let bind: SocketAddr = "127.0.0.1:6969".parse()
         179  +
//!        .expect("unable to parse the server bind address and port");
         180  +
//!    let server = ::hyper::Server::bind(&bind).serve(app.into_make_service());
         181  +
//!    # let server = async { Ok::<_, ()>(()) };
         182  +
//!
         183  +
//!    // Run your service!
         184  +
//!    if let Err(err) = server.await {
         185  +
//!        eprintln!("server error: {:?}", err);
         186  +
//!    }
         187  +
//! }
         188  +
//!
         189  +
//! use pokemon_service_awsjson_server_sdk_http0x::{input, output, error};
         190  +
//!
         191  +
//! async fn capture_pokemon(input: input::CapturePokemonInput) -> Result<output::CapturePokemonOutput, error::CapturePokemonError> {
         192  +
//!     todo!()
         193  +
//! }
         194  +
//!
         195  +
//! async fn check_health(input: input::CheckHealthInput) -> output::CheckHealthOutput {
         196  +
//!     todo!()
         197  +
//! }
         198  +
//!
         199  +
//! async fn do_nothing(input: input::DoNothingInput) -> output::DoNothingOutput {
         200  +
//!     todo!()
         201  +
//! }
         202  +
//!
         203  +
//! async fn get_server_statistics(input: input::GetServerStatisticsInput) -> output::GetServerStatisticsOutput {
         204  +
//!     todo!()
         205  +
//! }
         206  +
//!
         207  +
//! ```
         208  +
//!
         209  +
//! [`serve`]: https://docs.rs/hyper/0.14.16/hyper/server/struct.Builder.html#method.serve
         210  +
//! [hyper server]: https://docs.rs/hyper/0.14.26/hyper/server/index.html
         211  +
//! [`tower::make::MakeService`]: https://docs.rs/tower/latest/tower/make/trait.MakeService.html
         212  +
//! [HTTP binding traits]: https://smithy.io/2.0/spec/http-bindings.html
         213  +
//! [operations]: https://smithy.io/2.0/spec/service-types.html#operation
         214  +
//! [Service]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
         215  +
pub use crate::service::{
         216  +
    MissingOperationsError, PokemonService, PokemonServiceBuilder, PokemonServiceConfig,
         217  +
    PokemonServiceConfigBuilder,
         218  +
};
         219  +
         220  +
/// Contains the types that are re-exported from the `aws-smithy-http-server` crate.
         221  +
pub mod server {
         222  +
    // Re-export all types from the `aws-smithy-http-server` crate.
         223  +
    pub use ::aws_smithy_legacy_http_server::*;
         224  +
}
         225  +
         226  +
/// Crate version number.
         227  +
pub static PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
         228  +
         229  +
/// All error types that operations can return. Documentation on these types is copied from the model.
         230  +
pub mod error;
         231  +
         232  +
/// Input structures for operations. Documentation on these types is copied from the model.
         233  +
pub mod input;
         234  +
         235  +
/// Data structures used by operation inputs/outputs. Documentation on these types is copied from the model.
         236  +
pub mod model;
         237  +
         238  +
/// All operations that this crate can perform.
         239  +
pub mod operation;
         240  +
         241  +
/// A collection of types representing each operation defined in the service closure.
         242  +
///
         243  +
/// The [plugin system](::aws_smithy_legacy_http_server::plugin) makes use of these
         244  +
/// [zero-sized types](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts) (ZSTs) to
         245  +
/// parameterize [`Plugin`](::aws_smithy_legacy_http_server::plugin::Plugin) implementations. Their traits, such as
         246  +
/// [`OperationShape`](::aws_smithy_legacy_http_server::operation::OperationShape), can be used to provide
         247  +
/// operation specific information to the [`Layer`](::tower::Layer) being applied.
         248  +
pub mod operation_shape;
         249  +
         250  +
/// Output structures for operations. Documentation on these types is copied from the model.
         251  +
pub mod output;
         252  +
         253  +
mod service;
         254  +
         255  +
/// Data primitives referenced by other data types.
         256  +
pub mod types;
         257  +
         258  +
/// Constrained types for constrained shapes.
         259  +
mod constrained;
         260  +
         261  +
mod mimes;
         262  +
         263  +
mod event_stream_serde;
         264  +
         265  +
pub(crate) mod protocol_serde;

tmp-codegen-diff/codegen-server-test/pokemon-service-awsjson-server-sdk-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_X_AMZ_JSON_1_0: std::sync::LazyLock<::mime::Mime> =
           3  +
    std::sync::LazyLock::new(|| {
           4  +
        "application/x-amz-json-1.0"
           5  +
            .parse::<::mime::Mime>()
           6  +
            .expect("BUG: MIME parsing failed, content_type is not valid")
           7  +
    });

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

@@ -0,1 +0,381 @@
           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  +
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
          34  +
pub enum CapturePokemonEvents {
          35  +
    #[allow(missing_docs)] // documentation missing in model
          36  +
    Event(crate::model::CaptureEvent),
          37  +
}
          38  +
impl CapturePokemonEvents {
          39  +
    #[allow(irrefutable_let_patterns)]
          40  +
    /// Tries to convert the enum instance into [`Event`](crate::model::CapturePokemonEvents::Event), extracting the inner [`CaptureEvent`](crate::model::CaptureEvent).
          41  +
    /// Returns `Err(&Self)` if it can't be converted.
          42  +
    pub fn as_event(&self) -> ::std::result::Result<&crate::model::CaptureEvent, &Self> {
          43  +
        if let CapturePokemonEvents::Event(val) = &self {
          44  +
            ::std::result::Result::Ok(val)
          45  +
        } else {
          46  +
            ::std::result::Result::Err(self)
          47  +
        }
          48  +
    }
          49  +
    /// Returns true if this is a [`Event`](crate::model::CapturePokemonEvents::Event).
          50  +
    pub fn is_event(&self) -> bool {
          51  +
        self.as_event().is_ok()
          52  +
    }
          53  +
}
          54  +
          55  +
#[allow(missing_docs)] // documentation missing in model
          56  +
#[derive(
          57  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
          58  +
)]
          59  +
pub struct CaptureEvent {
          60  +
    #[allow(missing_docs)] // documentation missing in model
          61  +
    pub name: ::std::option::Option<::std::string::String>,
          62  +
    #[allow(missing_docs)] // documentation missing in model
          63  +
    pub captured: ::std::option::Option<bool>,
          64  +
    #[allow(missing_docs)] // documentation missing in model
          65  +
    pub shiny: ::std::option::Option<bool>,
          66  +
    #[allow(missing_docs)] // documentation missing in model
          67  +
    pub pokedex_update: ::std::option::Option<::aws_smithy_types::Blob>,
          68  +
}
          69  +
impl CaptureEvent {
          70  +
    #[allow(missing_docs)] // documentation missing in model
          71  +
    pub fn name(&self) -> ::std::option::Option<&str> {
          72  +
        self.name.as_deref()
          73  +
    }
          74  +
    #[allow(missing_docs)] // documentation missing in model
          75  +
    pub fn captured(&self) -> ::std::option::Option<bool> {
          76  +
        self.captured
          77  +
    }
          78  +
    #[allow(missing_docs)] // documentation missing in model
          79  +
    pub fn shiny(&self) -> ::std::option::Option<bool> {
          80  +
        self.shiny
          81  +
    }
          82  +
    #[allow(missing_docs)] // documentation missing in model
          83  +
    pub fn pokedex_update(&self) -> ::std::option::Option<&::aws_smithy_types::Blob> {
          84  +
        self.pokedex_update.as_ref()
          85  +
    }
          86  +
}
          87  +
impl CaptureEvent {
          88  +
    /// Creates a new builder-style object to manufacture [`CaptureEvent`](crate::model::CaptureEvent).
          89  +
    pub fn builder() -> crate::model::capture_event::Builder {
          90  +
        crate::model::capture_event::Builder::default()
          91  +
    }
          92  +
}
          93  +
          94  +
#[allow(missing_docs)] // documentation missing in model
          95  +
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
          96  +
pub enum AttemptCapturingPokemonEvent {
          97  +
    #[allow(missing_docs)] // documentation missing in model
          98  +
    Event(crate::model::CapturingEvent),
          99  +
}
         100  +
impl AttemptCapturingPokemonEvent {
         101  +
    #[allow(irrefutable_let_patterns)]
         102  +
    /// Tries to convert the enum instance into [`Event`](crate::model::AttemptCapturingPokemonEvent::Event), extracting the inner [`CapturingEvent`](crate::model::CapturingEvent).
         103  +
    /// Returns `Err(&Self)` if it can't be converted.
         104  +
    pub fn as_event(&self) -> ::std::result::Result<&crate::model::CapturingEvent, &Self> {
         105  +
        if let AttemptCapturingPokemonEvent::Event(val) = &self {
         106  +
            ::std::result::Result::Ok(val)
         107  +
        } else {
         108  +
            ::std::result::Result::Err(self)
         109  +
        }
         110  +
    }
         111  +
    /// Returns true if this is a [`Event`](crate::model::AttemptCapturingPokemonEvent::Event).
         112  +
    pub fn is_event(&self) -> bool {
         113  +
        self.as_event().is_ok()
         114  +
    }
         115  +
}
         116  +
         117  +
#[allow(missing_docs)] // documentation missing in model
         118  +
#[derive(
         119  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         120  +
)]
         121  +
pub struct CapturingEvent {
         122  +
    #[allow(missing_docs)] // documentation missing in model
         123  +
    pub payload: ::std::option::Option<crate::model::CapturingPayload>,
         124  +
}
         125  +
impl CapturingEvent {
         126  +
    #[allow(missing_docs)] // documentation missing in model
         127  +
    pub fn payload(&self) -> ::std::option::Option<&crate::model::CapturingPayload> {
         128  +
        self.payload.as_ref()
         129  +
    }
         130  +
}
         131  +
impl CapturingEvent {
         132  +
    /// Creates a new builder-style object to manufacture [`CapturingEvent`](crate::model::CapturingEvent).
         133  +
    pub fn builder() -> crate::model::capturing_event::Builder {
         134  +
        crate::model::capturing_event::Builder::default()
         135  +
    }
         136  +
}
         137  +
impl crate::constrained::Constrained for crate::model::CapturingEvent {
         138  +
    type Unconstrained = crate::model::capturing_event::Builder;
         139  +
}
         140  +
         141  +
#[allow(missing_docs)] // documentation missing in model
         142  +
#[derive(
         143  +
    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::PartialEq, ::std::fmt::Debug, ::std::hash::Hash,
         144  +
)]
         145  +
pub struct CapturingPayload {
         146  +
    #[allow(missing_docs)] // documentation missing in model
         147  +
    pub name: ::std::option::Option<::std::string::String>,
         148  +
    #[allow(missing_docs)] // documentation missing in model
         149  +
    pub pokeball: ::std::option::Option<::std::string::String>,
         150  +
}
         151  +
impl CapturingPayload {
         152  +
    #[allow(missing_docs)] // documentation missing in model
         153  +
    pub fn name(&self) -> ::std::option::Option<&str> {
         154  +
        self.name.as_deref()
         155  +
    }
         156  +
    #[allow(missing_docs)] // documentation missing in model
         157  +
    pub fn pokeball(&self) -> ::std::option::Option<&str> {
         158  +
        self.pokeball.as_deref()
         159  +
    }
         160  +
}
         161  +
impl CapturingPayload {
         162  +
    /// Creates a new builder-style object to manufacture [`CapturingPayload`](crate::model::CapturingPayload).
         163  +
    pub fn builder() -> crate::model::capturing_payload::Builder {
         164  +
        crate::model::capturing_payload::Builder::default()
         165  +
    }
         166  +
}
         167  +
impl crate::constrained::Constrained for crate::model::CapturingPayload {
         168  +
    type Unconstrained = crate::model::capturing_payload::Builder;
         169  +
}
         170  +
/// See [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         171  +
pub mod validation_exception_field {
         172  +
         173  +
    #[derive(::std::cmp::PartialEq, ::std::fmt::Debug)]
         174  +
    /// Holds one variant for each of the ways the builder can fail.
         175  +
    #[non_exhaustive]
         176  +
    #[allow(clippy::enum_variant_names)]
         177  +
    pub enum ConstraintViolation {
         178  +
        /// `path` was not provided but it is required when building `ValidationExceptionField`.
         179  +
        MissingPath,
         180  +
        /// `message` was not provided but it is required when building `ValidationExceptionField`.
         181  +
        MissingMessage,
         182  +
    }
         183  +
    impl ::std::fmt::Display for ConstraintViolation {
         184  +
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         185  +
            match self {
         186  +
                ConstraintViolation::MissingPath => write!(f, "`path` was not provided but it is required when building `ValidationExceptionField`"),
         187  +
                ConstraintViolation::MissingMessage => write!(f, "`message` was not provided but it is required when building `ValidationExceptionField`"),
         188  +
            }
         189  +
        }
         190  +
    }
         191  +
    impl ::std::error::Error for ConstraintViolation {}
         192  +
    impl ::std::convert::TryFrom<Builder> for crate::model::ValidationExceptionField {
         193  +
        type Error = ConstraintViolation;
         194  +
         195  +
        fn try_from(builder: Builder) -> ::std::result::Result<Self, Self::Error> {
         196  +
            builder.build()
         197  +
        }
         198  +
    }
         199  +
    /// A builder for [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         200  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         201  +
    pub struct Builder {
         202  +
        pub(crate) path: ::std::option::Option<::std::string::String>,
         203  +
        pub(crate) message: ::std::option::Option<::std::string::String>,
         204  +
    }
         205  +
    impl Builder {
         206  +
        /// A JSONPointer expression to the structure member whose value failed to satisfy the modeled constraints.
         207  +
        pub fn path(mut self, input: ::std::string::String) -> Self {
         208  +
            self.path = Some(input);
         209  +
            self
         210  +
        }
         211  +
        /// A detailed description of the validation failure.
         212  +
        pub fn message(mut self, input: ::std::string::String) -> Self {
         213  +
            self.message = Some(input);
         214  +
            self
         215  +
        }
         216  +
        /// Consumes the builder and constructs a [`ValidationExceptionField`](crate::model::ValidationExceptionField).
         217  +
        ///
         218  +
        /// The builder fails to construct a [`ValidationExceptionField`](crate::model::ValidationExceptionField) if a [`ConstraintViolation`] occurs.
         219  +
        ///
         220  +
        /// If the builder fails, it will return the _first_ encountered [`ConstraintViolation`].
         221  +
        pub fn build(self) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
         222  +
            self.build_enforcing_all_constraints()
         223  +
        }
         224  +
        fn build_enforcing_all_constraints(
         225  +
            self,
         226  +
        ) -> Result<crate::model::ValidationExceptionField, ConstraintViolation> {
         227  +
            Ok(crate::model::ValidationExceptionField {
         228  +
                path: self.path.ok_or(ConstraintViolation::MissingPath)?,
         229  +
                message: self.message.ok_or(ConstraintViolation::MissingMessage)?,
         230  +
            })
         231  +
        }
         232  +
    }
         233  +
}
         234  +
/// See [`CaptureEvent`](crate::model::CaptureEvent).
         235  +
pub mod capture_event {
         236  +
         237  +
    impl ::std::convert::From<Builder> for crate::model::CaptureEvent {
         238  +
        fn from(builder: Builder) -> Self {
         239  +
            builder.build()
         240  +
        }
         241  +
    }
         242  +
    /// A builder for [`CaptureEvent`](crate::model::CaptureEvent).
         243  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         244  +
    pub struct Builder {
         245  +
        pub(crate) name: ::std::option::Option<::std::string::String>,
         246  +
        pub(crate) captured: ::std::option::Option<bool>,
         247  +
        pub(crate) shiny: ::std::option::Option<bool>,
         248  +
        pub(crate) pokedex_update: ::std::option::Option<::aws_smithy_types::Blob>,
         249  +
    }
         250  +
    impl Builder {
         251  +
        #[allow(missing_docs)] // documentation missing in model
         252  +
        pub fn name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         253  +
            self.name = input;
         254  +
            self
         255  +
        }
         256  +
        #[allow(missing_docs)] // documentation missing in model
         257  +
        pub fn captured(mut self, input: ::std::option::Option<bool>) -> Self {
         258  +
            self.captured = input;
         259  +
            self
         260  +
        }
         261  +
        #[allow(missing_docs)] // documentation missing in model
         262  +
        pub fn shiny(mut self, input: ::std::option::Option<bool>) -> Self {
         263  +
            self.shiny = input;
         264  +
            self
         265  +
        }
         266  +
        #[allow(missing_docs)] // documentation missing in model
         267  +
        pub fn pokedex_update(
         268  +
            mut self,
         269  +
            input: ::std::option::Option<::aws_smithy_types::Blob>,
         270  +
        ) -> Self {
         271  +
            self.pokedex_update = input;
         272  +
            self
         273  +
        }
         274  +
        /// Consumes the builder and constructs a [`CaptureEvent`](crate::model::CaptureEvent).
         275  +
        pub fn build(self) -> crate::model::CaptureEvent {
         276  +
            self.build_enforcing_all_constraints()
         277  +
        }
         278  +
        fn build_enforcing_all_constraints(self) -> crate::model::CaptureEvent {
         279  +
            crate::model::CaptureEvent {
         280  +
                name: self.name,
         281  +
                captured: self.captured,
         282  +
                shiny: self.shiny,
         283  +
                pokedex_update: self.pokedex_update,
         284  +
            }
         285  +
        }
         286  +
    }
         287  +
}
         288  +
/// See [`CapturingEvent`](crate::model::CapturingEvent).
         289  +
pub mod capturing_event {
         290  +
         291  +
    impl ::std::convert::From<Builder> for crate::model::CapturingEvent {
         292  +
        fn from(builder: Builder) -> Self {
         293  +
            builder.build()
         294  +
        }
         295  +
    }
         296  +
    /// A builder for [`CapturingEvent`](crate::model::CapturingEvent).
         297  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         298  +
    pub struct Builder {
         299  +
        pub(crate) payload: ::std::option::Option<crate::model::CapturingPayload>,
         300  +
    }
         301  +
    impl Builder {
         302  +
        #[allow(missing_docs)] // documentation missing in model
         303  +
        pub fn payload(
         304  +
            mut self,
         305  +
            input: ::std::option::Option<crate::model::CapturingPayload>,
         306  +
        ) -> Self {
         307  +
            self.payload = input;
         308  +
            self
         309  +
        }
         310  +
        #[allow(missing_docs)] // documentation missing in model
         311  +
        pub(crate) fn set_payload(
         312  +
            mut self,
         313  +
            input: Option<impl ::std::convert::Into<crate::model::CapturingPayload>>,
         314  +
        ) -> Self {
         315  +
            self.payload = input.map(|v| v.into());
         316  +
            self
         317  +
        }
         318  +
        /// Consumes the builder and constructs a [`CapturingEvent`](crate::model::CapturingEvent).
         319  +
        pub fn build(self) -> crate::model::CapturingEvent {
         320  +
            self.build_enforcing_all_constraints()
         321  +
        }
         322  +
        fn build_enforcing_all_constraints(self) -> crate::model::CapturingEvent {
         323  +
            crate::model::CapturingEvent {
         324  +
                payload: self.payload,
         325  +
            }
         326  +
        }
         327  +
    }
         328  +
}
         329  +
/// See [`CapturingPayload`](crate::model::CapturingPayload).
         330  +
pub mod capturing_payload {
         331  +
         332  +
    impl ::std::convert::From<Builder> for crate::model::CapturingPayload {
         333  +
        fn from(builder: Builder) -> Self {
         334  +
            builder.build()
         335  +
        }
         336  +
    }
         337  +
    /// A builder for [`CapturingPayload`](crate::model::CapturingPayload).
         338  +
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
         339  +
    pub struct Builder {
         340  +
        pub(crate) name: ::std::option::Option<::std::string::String>,
         341  +
        pub(crate) pokeball: ::std::option::Option<::std::string::String>,
         342  +
    }
         343  +
    impl Builder {
         344  +
        #[allow(missing_docs)] // documentation missing in model
         345  +
        pub fn name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         346  +
            self.name = input;
         347  +
            self
         348  +
        }
         349  +
        #[allow(missing_docs)] // documentation missing in model
         350  +
        pub(crate) fn set_name(
         351  +
            mut self,
         352  +
            input: Option<impl ::std::convert::Into<::std::string::String>>,
         353  +
        ) -> Self {
         354  +
            self.name = input.map(|v| v.into());
         355  +
            self
         356  +
        }
         357  +
        #[allow(missing_docs)] // documentation missing in model
         358  +
        pub fn pokeball(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
         359  +
            self.pokeball = input;
         360  +
            self
         361  +
        }
         362  +
        #[allow(missing_docs)] // documentation missing in model
         363  +
        pub(crate) fn set_pokeball(
         364  +
            mut self,
         365  +
            input: Option<impl ::std::convert::Into<::std::string::String>>,
         366  +
        ) -> Self {
         367  +
            self.pokeball = input.map(|v| v.into());
         368  +
            self
         369  +
        }
         370  +
        /// Consumes the builder and constructs a [`CapturingPayload`](crate::model::CapturingPayload).
         371  +
        pub fn build(self) -> crate::model::CapturingPayload {
         372  +
            self.build_enforcing_all_constraints()
         373  +
        }
         374  +
        fn build_enforcing_all_constraints(self) -> crate::model::CapturingPayload {
         375  +
            crate::model::CapturingPayload {
         376  +
                name: self.name,
         377  +
                pokeball: self.pokeball,
         378  +
            }
         379  +
        }
         380  +
    }
         381  +
}

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

@@ -0,1 +0,330 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
::pin_project_lite::pin_project! {
           3  +
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
           4  +
    /// [`CheckHealthInput`](crate::input::CheckHealthInput) using modelled bindings.
           5  +
    pub struct CheckHealthInputFuture {
           6  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::CheckHealthInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
           7  +
    }
           8  +
}
           9  +
          10  +
impl std::future::Future for CheckHealthInputFuture {
          11  +
    type Output = Result<
          12  +
        crate::input::CheckHealthInput,
          13  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
          14  +
    >;
          15  +
          16  +
    fn poll(
          17  +
        self: std::pin::Pin<&mut Self>,
          18  +
        cx: &mut std::task::Context<'_>,
          19  +
    ) -> std::task::Poll<Self::Output> {
          20  +
        let this = self.project();
          21  +
        this.inner.as_mut().poll(cx)
          22  +
    }
          23  +
}
          24  +
          25  +
impl<B>
          26  +
    ::aws_smithy_legacy_http_server::request::FromRequest<
          27  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
          28  +
        B,
          29  +
    > for crate::input::CheckHealthInput
          30  +
where
          31  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          32  +
    B: 'static,
          33  +
          34  +
    B::Data: Send,
          35  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
          36  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          37  +
{
          38  +
    type Rejection =
          39  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
          40  +
    type Future = CheckHealthInputFuture;
          41  +
          42  +
    fn from_request(request: ::http::Request<B>) -> Self::Future {
          43  +
        let fut = async move {
          44  +
            if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
          45  +
                request.headers(),
          46  +
                &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
          47  +
            ) {
          48  +
                return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
          49  +
            }
          50  +
            crate::protocol_serde::shape_check_health::de_check_health_http_request(request).await
          51  +
        };
          52  +
        use ::futures_util::future::TryFutureExt;
          53  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
          54  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
          55  +
                        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
          56  +
                    });
          57  +
        CheckHealthInputFuture {
          58  +
            inner: Box::pin(fut),
          59  +
        }
          60  +
    }
          61  +
}
          62  +
impl
          63  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
          64  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
          65  +
    > for crate::output::CheckHealthOutput
          66  +
{
          67  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
          68  +
        match crate::protocol_serde::shape_check_health::ser_check_health_http_response(self) {
          69  +
            Ok(response) => response,
          70  +
            Err(e) => {
          71  +
                ::tracing::error!(error = %e, "failed to serialize response");
          72  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
          73  +
            }
          74  +
        }
          75  +
    }
          76  +
}
          77  +
          78  +
::pin_project_lite::pin_project! {
          79  +
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
          80  +
    /// [`CapturePokemonInput`](crate::input::CapturePokemonInput) using modelled bindings.
          81  +
    pub struct CapturePokemonInputFuture {
          82  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::CapturePokemonInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
          83  +
    }
          84  +
}
          85  +
          86  +
impl std::future::Future for CapturePokemonInputFuture {
          87  +
    type Output = Result<
          88  +
        crate::input::CapturePokemonInput,
          89  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
          90  +
    >;
          91  +
          92  +
    fn poll(
          93  +
        self: std::pin::Pin<&mut Self>,
          94  +
        cx: &mut std::task::Context<'_>,
          95  +
    ) -> std::task::Poll<Self::Output> {
          96  +
        let this = self.project();
          97  +
        this.inner.as_mut().poll(cx)
          98  +
    }
          99  +
}
         100  +
         101  +
impl<B>
         102  +
    ::aws_smithy_legacy_http_server::request::FromRequest<
         103  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         104  +
        B,
         105  +
    > for crate::input::CapturePokemonInput
         106  +
where
         107  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
         108  +
    B: 'static,
         109  +
         110  +
    B: Into<::aws_smithy_types::byte_stream::ByteStream>,
         111  +
    B::Data: Send,
         112  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
         113  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
         114  +
{
         115  +
    type Rejection =
         116  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
         117  +
    type Future = CapturePokemonInputFuture;
         118  +
         119  +
    fn from_request(request: ::http::Request<B>) -> Self::Future {
         120  +
        let fut = async move {
         121  +
            if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
         122  +
                request.headers(),
         123  +
                &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
         124  +
            ) {
         125  +
                return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
         126  +
            }
         127  +
            crate::protocol_serde::shape_capture_pokemon::de_capture_pokemon_http_request(request)
         128  +
                .await
         129  +
        };
         130  +
        use ::futures_util::future::TryFutureExt;
         131  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
         132  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
         133  +
                        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
         134  +
                    });
         135  +
        CapturePokemonInputFuture {
         136  +
            inner: Box::pin(fut),
         137  +
        }
         138  +
    }
         139  +
}
         140  +
impl
         141  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
         142  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         143  +
    > for crate::output::CapturePokemonOutput
         144  +
{
         145  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
         146  +
        match crate::protocol_serde::shape_capture_pokemon::ser_capture_pokemon_http_response(self)
         147  +
        {
         148  +
            Ok(response) => response,
         149  +
            Err(e) => {
         150  +
                ::tracing::error!(error = %e, "failed to serialize response");
         151  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
         152  +
            }
         153  +
        }
         154  +
    }
         155  +
}
         156  +
impl
         157  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
         158  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         159  +
    > for crate::error::CapturePokemonError
         160  +
{
         161  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
         162  +
        match crate::protocol_serde::shape_capture_pokemon::ser_capture_pokemon_http_error(&self) {
         163  +
            Ok(mut response) => {
         164  +
                response.extensions_mut().insert(
         165  +
                    ::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(
         166  +
                        self.name(),
         167  +
                    ),
         168  +
                );
         169  +
                response
         170  +
            }
         171  +
            Err(e) => {
         172  +
                ::tracing::error!(error = %e, "failed to serialize response");
         173  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
         174  +
            }
         175  +
        }
         176  +
    }
         177  +
}
         178  +
         179  +
::pin_project_lite::pin_project! {
         180  +
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
         181  +
    /// [`DoNothingInput`](crate::input::DoNothingInput) using modelled bindings.
         182  +
    pub struct DoNothingInputFuture {
         183  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::DoNothingInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
         184  +
    }
         185  +
}
         186  +
         187  +
impl std::future::Future for DoNothingInputFuture {
         188  +
    type Output = Result<
         189  +
        crate::input::DoNothingInput,
         190  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
         191  +
    >;
         192  +
         193  +
    fn poll(
         194  +
        self: std::pin::Pin<&mut Self>,
         195  +
        cx: &mut std::task::Context<'_>,
         196  +
    ) -> std::task::Poll<Self::Output> {
         197  +
        let this = self.project();
         198  +
        this.inner.as_mut().poll(cx)
         199  +
    }
         200  +
}
         201  +
         202  +
impl<B>
         203  +
    ::aws_smithy_legacy_http_server::request::FromRequest<
         204  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         205  +
        B,
         206  +
    > for crate::input::DoNothingInput
         207  +
where
         208  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
         209  +
    B: 'static,
         210  +
         211  +
    B::Data: Send,
         212  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
         213  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
         214  +
{
         215  +
    type Rejection =
         216  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
         217  +
    type Future = DoNothingInputFuture;
         218  +
         219  +
    fn from_request(request: ::http::Request<B>) -> Self::Future {
         220  +
        let fut = async move {
         221  +
            if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
         222  +
                request.headers(),
         223  +
                &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
         224  +
            ) {
         225  +
                return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
         226  +
            }
         227  +
            crate::protocol_serde::shape_do_nothing::de_do_nothing_http_request(request).await
         228  +
        };
         229  +
        use ::futures_util::future::TryFutureExt;
         230  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
         231  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
         232  +
                        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
         233  +
                    });
         234  +
        DoNothingInputFuture {
         235  +
            inner: Box::pin(fut),
         236  +
        }
         237  +
    }
         238  +
}
         239  +
impl
         240  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
         241  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         242  +
    > for crate::output::DoNothingOutput
         243  +
{
         244  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
         245  +
        match crate::protocol_serde::shape_do_nothing::ser_do_nothing_http_response(self) {
         246  +
            Ok(response) => response,
         247  +
            Err(e) => {
         248  +
                ::tracing::error!(error = %e, "failed to serialize response");
         249  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
         250  +
            }
         251  +
        }
         252  +
    }
         253  +
}
         254  +
         255  +
::pin_project_lite::pin_project! {
         256  +
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
         257  +
    /// [`GetServerStatisticsInput`](crate::input::GetServerStatisticsInput) using modelled bindings.
         258  +
    pub struct GetServerStatisticsInputFuture {
         259  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::GetServerStatisticsInput, ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError>> + Send>>
         260  +
    }
         261  +
}
         262  +
         263  +
impl std::future::Future for GetServerStatisticsInputFuture {
         264  +
    type Output = Result<
         265  +
        crate::input::GetServerStatisticsInput,
         266  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError,
         267  +
    >;
         268  +
         269  +
    fn poll(
         270  +
        self: std::pin::Pin<&mut Self>,
         271  +
        cx: &mut std::task::Context<'_>,
         272  +
    ) -> std::task::Poll<Self::Output> {
         273  +
        let this = self.project();
         274  +
        this.inner.as_mut().poll(cx)
         275  +
    }
         276  +
}
         277  +
         278  +
impl<B>
         279  +
    ::aws_smithy_legacy_http_server::request::FromRequest<
         280  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         281  +
        B,
         282  +
    > for crate::input::GetServerStatisticsInput
         283  +
where
         284  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
         285  +
    B: 'static,
         286  +
         287  +
    B::Data: Send,
         288  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection:
         289  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
         290  +
{
         291  +
    type Rejection =
         292  +
        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError;
         293  +
    type Future = GetServerStatisticsInputFuture;
         294  +
         295  +
    fn from_request(request: ::http::Request<B>) -> Self::Future {
         296  +
        let fut = async move {
         297  +
            if !::aws_smithy_legacy_http_server::protocol::accept_header_classifier(
         298  +
                request.headers(),
         299  +
                &crate::mimes::CONTENT_TYPE_APPLICATION_X_AMZ_JSON_1_0,
         300  +
            ) {
         301  +
                return Err(::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection::NotAcceptable);
         302  +
            }
         303  +
            crate::protocol_serde::shape_get_server_statistics::de_get_server_statistics_http_request(request)
         304  +
                            .await
         305  +
        };
         306  +
        use ::futures_util::future::TryFutureExt;
         307  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::RequestRejection| {
         308  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
         309  +
                        ::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e)
         310  +
                    });
         311  +
        GetServerStatisticsInputFuture {
         312  +
            inner: Box::pin(fut),
         313  +
        }
         314  +
    }
         315  +
}
         316  +
impl
         317  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
         318  +
        ::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0,
         319  +
    > for crate::output::GetServerStatisticsOutput
         320  +
{
         321  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
         322  +
        match crate::protocol_serde::shape_get_server_statistics::ser_get_server_statistics_http_response(self) {
         323  +
                        Ok(response) => response,
         324  +
                        Err(e) => {
         325  +
                            ::tracing::error!(error = %e, "failed to serialize response");
         326  +
                            ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::aws_json_10::AwsJson1_0>::into_response(::aws_smithy_legacy_http_server::protocol::aws_json::runtime_error::RuntimeError::from(e))
         327  +
                        }
         328  +
                    }
         329  +
    }
         330  +
}

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

@@ -0,1 +0,148 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
           3  +
/// Health check operation, to check the service is up Not yet a deep check
           4  +
pub struct CheckHealth;
           5  +
           6  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for CheckHealth {
           7  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
           8  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
           9  +
            "com.aws.example#CheckHealth",
          10  +
            "com.aws.example",
          11  +
            "CheckHealth",
          12  +
        );
          13  +
          14  +
    type Input = crate::input::CheckHealthInput;
          15  +
    type Output = crate::output::CheckHealthOutput;
          16  +
    type Error = std::convert::Infallible;
          17  +
}
          18  +
          19  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity for CheckHealth {
          20  +
    type RequestFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt<
          21  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          22  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::uri::MakeUri<
          23  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          24  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          25  +
        >,
          26  +
    >;
          27  +
    type ResponseFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt<
          28  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          29  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          30  +
    >;
          31  +
          32  +
    fn request_fmt() -> Self::RequestFmt {
          33  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
          34  +
    }
          35  +
          36  +
    fn response_fmt() -> Self::ResponseFmt {
          37  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
          38  +
    }
          39  +
}
          40  +
          41  +
/// Capture Pokémons via event streams.
          42  +
pub struct CapturePokemon;
          43  +
          44  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for CapturePokemon {
          45  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
          46  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
          47  +
            "com.aws.example#CapturePokemon",
          48  +
            "com.aws.example",
          49  +
            "CapturePokemon",
          50  +
        );
          51  +
          52  +
    type Input = crate::input::CapturePokemonInput;
          53  +
    type Output = crate::output::CapturePokemonOutput;
          54  +
    type Error = crate::error::CapturePokemonError;
          55  +
}
          56  +
          57  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity for CapturePokemon {
          58  +
    type RequestFmt =
          59  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::DefaultRequestFmt;
          60  +
    type ResponseFmt =
          61  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::DefaultResponseFmt;
          62  +
          63  +
    fn request_fmt() -> Self::RequestFmt {
          64  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
          65  +
    }
          66  +
          67  +
    fn response_fmt() -> Self::ResponseFmt {
          68  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
          69  +
    }
          70  +
}
          71  +
          72  +
/// DoNothing operation, used to stress test the framework.
          73  +
pub struct DoNothing;
          74  +
          75  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for DoNothing {
          76  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
          77  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
          78  +
            "com.aws.example#DoNothing",
          79  +
            "com.aws.example",
          80  +
            "DoNothing",
          81  +
        );
          82  +
          83  +
    type Input = crate::input::DoNothingInput;
          84  +
    type Output = crate::output::DoNothingOutput;
          85  +
    type Error = std::convert::Infallible;
          86  +
}
          87  +
          88  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity for DoNothing {
          89  +
    type RequestFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt<
          90  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          91  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::uri::MakeUri<
          92  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          93  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          94  +
        >,
          95  +
    >;
          96  +
    type ResponseFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt<
          97  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          98  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          99  +
    >;
         100  +
         101  +
    fn request_fmt() -> Self::RequestFmt {
         102  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
         103  +
    }
         104  +
         105  +
    fn response_fmt() -> Self::ResponseFmt {
         106  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
         107  +
    }
         108  +
}
         109  +
         110  +
/// Retrieve HTTP server statistiscs, such as calls count.
         111  +
pub struct GetServerStatistics;
         112  +
         113  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for GetServerStatistics {
         114  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
         115  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
         116  +
            "com.aws.example#GetServerStatistics",
         117  +
            "com.aws.example",
         118  +
            "GetServerStatistics",
         119  +
        );
         120  +
         121  +
    type Input = crate::input::GetServerStatisticsInput;
         122  +
    type Output = crate::output::GetServerStatisticsOutput;
         123  +
    type Error = std::convert::Infallible;
         124  +
}
         125  +
         126  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity
         127  +
    for GetServerStatistics
         128  +
{
         129  +
    type RequestFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt<
         130  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
         131  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::uri::MakeUri<
         132  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
         133  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
         134  +
        >,
         135  +
    >;
         136  +
    type ResponseFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt<
         137  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
         138  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
         139  +
    >;
         140  +
         141  +
    fn request_fmt() -> Self::RequestFmt {
         142  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
         143  +
    }
         144  +
         145  +
    fn response_fmt() -> Self::ResponseFmt {
         146  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
         147  +
    }
         148  +
}