Server Test

Server Test

rev. 0b749be6d000fdc7ef59d1bc26f1dce00358d95c

Files changed:

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

@@ -1,0 +58,0 @@
    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 ContentTypeParametersInput {
    7         -
    #[allow(missing_docs)] // documentation missing in model
    8         -
    pub value: ::std::option::Option<i32>,
    9         -
}
   10         -
impl ContentTypeParametersInput {
   11         -
    #[allow(missing_docs)] // documentation missing in model
   12         -
    pub fn value(&self) -> ::std::option::Option<i32> {
   13         -
        self.value
   14         -
    }
   15         -
}
   16         -
impl ContentTypeParametersInput {
   17         -
    /// Creates a new builder-style object to manufacture [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput).
   18         -
    pub fn builder() -> crate::input::content_type_parameters_input::Builder {
   19         -
        crate::input::content_type_parameters_input::Builder::default()
   20         -
    }
   21         -
}
   22         -
impl crate::constrained::Constrained for crate::input::ContentTypeParametersInput {
   23         -
    type Unconstrained = crate::input::content_type_parameters_input::Builder;
   24         -
}
   25         -
/// See [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput).
   26         -
///
   27         -
pub mod content_type_parameters_input {
   28         -
   29         -
    impl ::std::convert::From<Builder> for crate::input::ContentTypeParametersInput {
   30         -
        fn from(builder: Builder) -> Self {
   31         -
            builder.build()
   32         -
        }
   33         -
    }
   34         -
    /// A builder for [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput).
   35         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
   36         -
    pub struct Builder {
   37         -
        pub(crate) value: ::std::option::Option<i32>,
   38         -
    }
   39         -
    impl Builder {
   40         -
        #[allow(missing_docs)] // documentation missing in model
   41         -
        pub fn value(mut self, input: ::std::option::Option<i32>) -> Self {
   42         -
            self.value = input;
   43         -
            self
   44         -
        }
   45         -
        #[allow(missing_docs)] // documentation missing in model
   46         -
        pub(crate) fn set_value(mut self, input: Option<impl ::std::convert::Into<i32>>) -> Self {
   47         -
            self.value = input.map(|v| v.into());
   48         -
            self
   49         -
        }
   50         -
        /// Consumes the builder and constructs a [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput).
   51         -
        pub fn build(self) -> crate::input::ContentTypeParametersInput {
   52         -
            self.build_enforcing_all_constraints()
   53         -
        }
   54         -
        fn build_enforcing_all_constraints(self) -> crate::input::ContentTypeParametersInput {
   55         -
            crate::input::ContentTypeParametersInput { value: self.value }
   56         -
        }
   57         -
    }
   58         -
}

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

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

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

@@ -1,0 +126,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
    3         -
::pin_project_lite::pin_project! {
    4         -
    /// A [`Future`](std::future::Future) aggregating the body bytes of a [`Request`] and constructing the
    5         -
    /// [`ContentTypeParametersInput`](crate::input::ContentTypeParametersInput) using modelled bindings.
    6         -
    pub struct ContentTypeParametersInputFuture {
    7         -
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::ContentTypeParametersInput, ::aws_smithy_http_server::protocol::rest_xml::runtime_error::RuntimeError>> + Send>>
    8         -
    }
    9         -
}
   10         -
   11         -
impl std::future::Future for ContentTypeParametersInputFuture {
   12         -
    type Output = Result<
   13         -
        crate::input::ContentTypeParametersInput,
   14         -
        ::aws_smithy_http_server::protocol::rest_xml::runtime_error::RuntimeError,
   15         -
    >;
   16         -
   17         -
    fn poll(
   18         -
        self: std::pin::Pin<&mut Self>,
   19         -
        cx: &mut std::task::Context<'_>,
   20         -
    ) -> std::task::Poll<Self::Output> {
   21         -
        let this = self.project();
   22         -
        this.inner.as_mut().poll(cx)
   23         -
    }
   24         -
}
   25         -
   26         -
impl<B>
   27         -
    ::aws_smithy_http_server::request::FromRequest<
   28         -
        ::aws_smithy_http_server::protocol::rest_xml::RestXml,
   29         -
        B,
   30         -
    > for crate::input::ContentTypeParametersInput
   31         -
where
   32         -
    B: ::aws_smithy_http_server::body::HttpBody + Send,
   33         -
    B: 'static,
   34         -
   35         -
    B::Data: Send,
   36         -
    ::aws_smithy_http_server::protocol::rest_xml::rejection::RequestRejection:
   37         -
        From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
   38         -
{
   39         -
    type Rejection = ::aws_smithy_http_server::protocol::rest_xml::runtime_error::RuntimeError;
   40         -
    type Future = ContentTypeParametersInputFuture;
   41         -
   42         -
    fn from_request(request: ::http::Request<B>) -> Self::Future {
   43         -
        let fut = async move {
   44         -
            crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters_http_request(request)
   45         -
                            .await
   46         -
                            .map_err(Into::into)
   47         -
        };
   48         -
        use ::futures_util::future::TryFutureExt;
   49         -
        let fut = fut.map_err(
   50         -
            |e: ::aws_smithy_http_server::protocol::rest_xml::rejection::RequestRejection| {
   51         -
                ::tracing::debug!(error = %e, "failed to deserialize request");
   52         -
                ::aws_smithy_http_server::protocol::rest_xml::runtime_error::RuntimeError::from(e)
   53         -
            },
   54         -
        );
   55         -
        ContentTypeParametersInputFuture {
   56         -
            inner: Box::pin(fut),
   57         -
        }
   58         -
    }
   59         -
}
   60         -
impl
   61         -
    ::aws_smithy_http_server::response::IntoResponse<
   62         -
        ::aws_smithy_http_server::protocol::rest_xml::RestXml,
   63         -
    > for crate::output::ContentTypeParametersOutput
   64         -
{
   65         -
    fn into_response(self) -> ::aws_smithy_http_server::response::Response {
   66         -
        match crate::protocol_serde::shape_content_type_parameters::ser_content_type_parameters_http_response(self) {
   67         -
                        Ok(response) => response,
   68         -
                        Err(e) => {
   69         -
                            ::tracing::error!(error = %e, "failed to serialize response");
   70         -
                            ::aws_smithy_http_server::response::IntoResponse::<::aws_smithy_http_server::protocol::rest_xml::RestXml>::into_response(::aws_smithy_http_server::protocol::rest_xml::runtime_error::RuntimeError::from(e))
   71         -
                        }
   72         -
                    }
   73         -
    }
   74         -
}
   75         -
   76         -
#[allow(unreachable_code, unused_variables)]
   77         -
#[cfg(test)]
   78         -
mod content_type_parameters_test {
   79         -
   80         -
    /// A server should ignore parameters added to the content type
   81         -
    /// Test ID: RestXmlMustSupportParametersInContentType
   82         -
    #[::tokio::test]
   83         -
    #[::tracing_test::traced_test]
   84         -
    async fn rest_xml_must_support_parameters_in_content_type_request() {
   85         -
        #[allow(unused_mut)]
   86         -
        let mut http_request = http::Request::builder()
   87         -
            .uri("/ContentTypeParameters")
   88         -
            .method("PUT")
   89         -
            .header("Content-Type", "application/xml; charset=utf-8")
   90         -
            .body(::aws_smithy_http_server::body::Body::from(
   91         -
                ::bytes::Bytes::from_static(
   92         -
                    "<ContentTypeParametersInput><value>5</value></ContentTypeParametersInput>"
   93         -
                        .as_bytes(),
   94         -
                ),
   95         -
            ))
   96         -
            .unwrap();
   97         -
        #[allow(unused_mut)]
   98         -
        let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
   99         -
        let config = crate::service::RestXmlExtrasConfig::builder().build();
  100         -
        let service =
  101         -
            crate::service::RestXmlExtras::builder::<::hyper::body::Body, _, _, _>(config)
  102         -
                .content_type_parameters(move |input: crate::input::ContentTypeParametersInput| {
  103         -
                    let sender = sender.clone();
  104         -
                    async move {
  105         -
                        let result = {
  106         -
                            let expected = crate::input::ContentTypeParametersInput {
  107         -
                                value: ::std::option::Option::Some(5),
  108         -
                            };
  109         -
                            ::pretty_assertions::assert_eq!(input, expected);
  110         -
                            let response = crate::output::ContentTypeParametersOutput {};
  111         -
                            response
  112         -
                        };
  113         -
                        sender.send(()).await.expect("receiver dropped early");
  114         -
                        result
  115         -
                    }
  116         -
                })
  117         -
                .build_unchecked();
  118         -
        let http_response = ::tower::ServiceExt::oneshot(service, http_request)
  119         -
            .await
  120         -
            .expect("unable to make an HTTP request");
  121         -
        assert!(
  122         -
            receiver.recv().await.is_some(),
  123         -
            "we expected operation handler to be invoked but it was not entered"
  124         -
        );
  125         -
    }
  126         -
}

tmp-codegen-diff/codegen-server-test/rest_xml_extras/rust-server-codegen/src/operation_shape.rs

@@ -1,0 +39,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
    3         -
/// The example tests how servers must support requests containing a `Content-Type` header with parameters.
    4         -
pub struct ContentTypeParameters;
    5         -
    6         -
impl ::aws_smithy_http_server::operation::OperationShape for ContentTypeParameters {
    7         -
    const ID: ::aws_smithy_http_server::shape_id::ShapeId =
    8         -
        ::aws_smithy_http_server::shape_id::ShapeId::new(
    9         -
            "aws.protocoltests.restxml#ContentTypeParameters",
   10         -
            "aws.protocoltests.restxml",
   11         -
            "ContentTypeParameters",
   12         -
        );
   13         -
   14         -
    type Input = crate::input::ContentTypeParametersInput;
   15         -
    type Output = crate::output::ContentTypeParametersOutput;
   16         -
    type Error = std::convert::Infallible;
   17         -
}
   18         -
   19         -
impl ::aws_smithy_http_server::instrumentation::sensitivity::Sensitivity for ContentTypeParameters {
   20         -
    type RequestFmt = ::aws_smithy_http_server::instrumentation::sensitivity::RequestFmt<
   21         -
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   22         -
        ::aws_smithy_http_server::instrumentation::sensitivity::uri::MakeUri<
   23         -
            ::aws_smithy_http_server::instrumentation::MakeIdentity,
   24         -
            ::aws_smithy_http_server::instrumentation::MakeIdentity,
   25         -
        >,
   26         -
    >;
   27         -
    type ResponseFmt = ::aws_smithy_http_server::instrumentation::sensitivity::ResponseFmt<
   28         -
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   29         -
        ::aws_smithy_http_server::instrumentation::MakeIdentity,
   30         -
    >;
   31         -
   32         -
    fn request_fmt() -> Self::RequestFmt {
   33         -
        ::aws_smithy_http_server::instrumentation::sensitivity::RequestFmt::new()
   34         -
    }
   35         -
   36         -
    fn response_fmt() -> Self::ResponseFmt {
   37         -
        ::aws_smithy_http_server::instrumentation::sensitivity::ResponseFmt::new()
   38         -
    }
   39         -
}

tmp-codegen-diff/codegen-server-test/rest_xml_extras/rust-server-codegen/src/output.rs

@@ -1,0 +34,0 @@
    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 ContentTypeParametersOutput {}
    7         -
impl ContentTypeParametersOutput {
    8         -
    /// Creates a new builder-style object to manufacture [`ContentTypeParametersOutput`](crate::output::ContentTypeParametersOutput).
    9         -
    pub fn builder() -> crate::output::content_type_parameters_output::Builder {
   10         -
        crate::output::content_type_parameters_output::Builder::default()
   11         -
    }
   12         -
}
   13         -
/// See [`ContentTypeParametersOutput`](crate::output::ContentTypeParametersOutput).
   14         -
///
   15         -
pub mod content_type_parameters_output {
   16         -
   17         -
    impl ::std::convert::From<Builder> for crate::output::ContentTypeParametersOutput {
   18         -
        fn from(builder: Builder) -> Self {
   19         -
            builder.build()
   20         -
        }
   21         -
    }
   22         -
    /// A builder for [`ContentTypeParametersOutput`](crate::output::ContentTypeParametersOutput).
   23         -
    #[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
   24         -
    pub struct Builder {}
   25         -
    impl Builder {
   26         -
        /// Consumes the builder and constructs a [`ContentTypeParametersOutput`](crate::output::ContentTypeParametersOutput).
   27         -
        pub fn build(self) -> crate::output::ContentTypeParametersOutput {
   28         -
            self.build_enforcing_all_constraints()
   29         -
        }
   30         -
        fn build_enforcing_all_constraints(self) -> crate::output::ContentTypeParametersOutput {
   31         -
            crate::output::ContentTypeParametersOutput {}
   32         -
        }
   33         -
    }
   34         -
}

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

@@ -1,0 +2,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub(crate) mod shape_content_type_parameters;

tmp-codegen-diff/codegen-server-test/rest_xml_extras/rust-server-codegen/src/server.rs

@@ -1,0 +39,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
pub mod body {
    3         -
    pub use ::aws_smithy_http_server::body::BoxBody;
    4         -
}
    5         -
pub mod operation {
    6         -
    pub use ::aws_smithy_http_server::operation::OperationShape;
    7         -
}
    8         -
pub mod plugin {
    9         -
    pub use ::aws_smithy_http_server::plugin::HttpMarker;
   10         -
    pub use ::aws_smithy_http_server::plugin::HttpPlugins;
   11         -
    pub use ::aws_smithy_http_server::plugin::ModelMarker;
   12         -
    pub use ::aws_smithy_http_server::plugin::ModelPlugins;
   13         -
    pub use ::aws_smithy_http_server::plugin::Plugin;
   14         -
    pub use ::aws_smithy_http_server::plugin::PluginStack;
   15         -
}
   16         -
pub mod request {
   17         -
    pub use ::aws_smithy_http_server::request::FromParts;
   18         -
   19         -
    #[cfg(feature = "aws-lambda")]
   20         -
    pub mod lambda {
   21         -
        pub use ::aws_smithy_http_server::request::lambda::Context;
   22         -
    }
   23         -
}
   24         -
pub mod response {
   25         -
    pub use ::aws_smithy_http_server::response::IntoResponse;
   26         -
}
   27         -
pub mod routing {
   28         -
    pub use ::aws_smithy_http_server::routing::IntoMakeService;
   29         -
    pub use ::aws_smithy_http_server::routing::IntoMakeServiceWithConnectInfo;
   30         -
    pub use ::aws_smithy_http_server::routing::Router;
   31         -
   32         -
    #[cfg(feature = "aws-lambda")]
   33         -
    pub use ::aws_smithy_http_server::routing::LambdaHandler;
   34         -
}
   35         -
   36         -
pub use ::aws_smithy_http_server::instrumentation;
   37         -
pub use ::aws_smithy_http_server::protocol;
   38         -
   39         -
pub use ::aws_smithy_http_server::Extension;

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

@@ -1,0 +720,0 @@
    1         -
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
    2         -
/// The service builder for [`RestXmlExtras`].
    3         -
///
    4         -
/// Constructed via [`RestXmlExtras::builder`].
    5         -
pub struct RestXmlExtrasBuilder<Body, L, HttpPl, ModelPl> {
    6         -
    content_type_parameters: Option<::aws_smithy_http_server::routing::Route<Body>>,
    7         -
    layer: L,
    8         -
    http_plugin: HttpPl,
    9         -
    model_plugin: ModelPl,
   10         -
}
   11         -
   12         -
impl<Body, L, HttpPl, ModelPl> RestXmlExtrasBuilder<Body, L, HttpPl, ModelPl> {
   13         -
    /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) operation.
   14         -
    ///
   15         -
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_http_server::operation::Handler) trait.
   16         -
    /// See the [operation module documentation](::aws_smithy_http_server::operation) for more information.
   17         -
    ///
   18         -
    /// # Example
   19         -
    ///
   20         -
    /// ```no_run
   21         -
    /// use rest_xml_extras::{RestXmlExtras, RestXmlExtrasConfig};
   22         -
    ///
   23         -
    /// use rest_xml_extras::{input, output};
   24         -
    ///
   25         -
    /// async fn handler(input: input::ContentTypeParametersInput) -> output::ContentTypeParametersOutput {
   26         -
    ///     todo!()
   27         -
    /// }
   28         -
    ///
   29         -
    /// let config = RestXmlExtrasConfig::builder().build();
   30         -
    /// let app = RestXmlExtras::builder(config)
   31         -
    ///     .content_type_parameters(handler)
   32         -
    ///     /* Set other handlers */
   33         -
    ///     .build()
   34         -
    ///     .unwrap();
   35         -
    /// # let app: RestXmlExtras<::aws_smithy_http_server::routing::RoutingService<::aws_smithy_http_server::protocol::rest::router::RestRouter<::aws_smithy_http_server::routing::Route>, ::aws_smithy_http_server::protocol::rest_xml::RestXml>> = app;
   36         -
    /// ```
   37         -
    ///
   38         -
                    pub fn content_type_parameters<HandlerType, HandlerExtractors, UpgradeExtractors>(self, handler: HandlerType) -> Self
   39         -
                    where
   40         -
                        HandlerType: ::aws_smithy_http_server::operation::Handler<crate::operation_shape::ContentTypeParameters, HandlerExtractors>,
   41         -
   42         -
                        ModelPl: ::aws_smithy_http_server::plugin::Plugin<
   43         -
                            RestXmlExtras<L>,
   44         -
                            crate::operation_shape::ContentTypeParameters,
   45         -
                            ::aws_smithy_http_server::operation::IntoService<crate::operation_shape::ContentTypeParameters, HandlerType>
   46         -
                        >,
   47         -
                        ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_http_server::plugin::Plugin<
   48         -
                            RestXmlExtras<L>,
   49         -
                            crate::operation_shape::ContentTypeParameters,
   50         -
                            ModelPl::Output
   51         -
                        >,
   52         -
                        HttpPl: ::aws_smithy_http_server::plugin::Plugin<
   53         -
                            RestXmlExtras<L>,
   54         -
                            crate::operation_shape::ContentTypeParameters,
   55         -
                            <
   56         -
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
   57         -
                                as ::aws_smithy_http_server::plugin::Plugin<
   58         -
                                    RestXmlExtras<L>,
   59         -
                                    crate::operation_shape::ContentTypeParameters,
   60         -
                                    ModelPl::Output
   61         -
                                >
   62         -
                            >::Output
   63         -
                        >,
   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,
   67         -
   68         -
                    {
   69         -
        use ::aws_smithy_http_server::operation::OperationShapeExt;
   70         -
        use ::aws_smithy_http_server::plugin::Plugin;
   71         -
        let svc = crate::operation_shape::ContentTypeParameters::from_handler(handler);
   72         -
        let svc = self.model_plugin.apply(svc);
   73         -
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
   74         -
            .apply(svc);
   75         -
        let svc = self.http_plugin.apply(svc);
   76         -
        self.content_type_parameters_custom(svc)
   77         -
    }
   78         -
   79         -
    /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) operation.
   80         -
    ///
   81         -
    /// This should be an async function satisfying the [`Handler`](::aws_smithy_http_server::operation::Handler) trait.
   82         -
    /// See the [operation module documentation](::aws_smithy_http_server::operation) for more information.
   83         -
    ///
   84         -
    /// # Example
   85         -
    ///
   86         -
    /// ```no_run
   87         -
    /// use rest_xml_extras::{RestXmlExtras, RestXmlExtrasConfig};
   88         -
    ///
   89         -
    /// use rest_xml_extras::{input, output};
   90         -
    ///
   91         -
    /// async fn handler(input: input::ContentTypeParametersInput) -> Result<output::ContentTypeParametersOutput, std::convert::Infallible> {
   92         -
    ///     todo!()
   93         -
    /// }
   94         -
    ///
   95         -
    /// let config = RestXmlExtrasConfig::builder().build();
   96         -
    /// let svc = ::tower::util::service_fn(handler);
   97         -
    /// let app = RestXmlExtras::builder(config)
   98         -
    ///     .content_type_parameters_service(svc)
   99         -
    ///     /* Set other handlers */
  100         -
    ///     .build()
  101         -
    ///     .unwrap();
  102         -
    /// # let app: RestXmlExtras<::aws_smithy_http_server::routing::RoutingService<::aws_smithy_http_server::protocol::rest::router::RestRouter<::aws_smithy_http_server::routing::Route>, ::aws_smithy_http_server::protocol::rest_xml::RestXml>> = app;
  103         -
    /// ```
  104         -
    ///
  105         -
                    pub fn content_type_parameters_service<S, ServiceExtractors, UpgradeExtractors>(self, service: S) -> Self
  106         -
                    where
  107         -
                        S: ::aws_smithy_http_server::operation::OperationService<crate::operation_shape::ContentTypeParameters, ServiceExtractors>,
  108         -
  109         -
                        ModelPl: ::aws_smithy_http_server::plugin::Plugin<
  110         -
                            RestXmlExtras<L>,
  111         -
                            crate::operation_shape::ContentTypeParameters,
  112         -
                            ::aws_smithy_http_server::operation::Normalize<crate::operation_shape::ContentTypeParameters, S>
  113         -
                        >,
  114         -
                        ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_http_server::plugin::Plugin<
  115         -
                            RestXmlExtras<L>,
  116         -
                            crate::operation_shape::ContentTypeParameters,
  117         -
                            ModelPl::Output
  118         -
                        >,
  119         -
                        HttpPl: ::aws_smithy_http_server::plugin::Plugin<
  120         -
                            RestXmlExtras<L>,
  121         -
                            crate::operation_shape::ContentTypeParameters,
  122         -
                            <
  123         -
                                ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
  124         -
                                as ::aws_smithy_http_server::plugin::Plugin<
  125         -
                                    RestXmlExtras<L>,
  126         -
                                    crate::operation_shape::ContentTypeParameters,
  127         -
                                    ModelPl::Output
  128         -
                                >
  129         -
                            >::Output
  130         -
                        >,
  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,
  134         -
  135         -
                    {
  136         -
        use ::aws_smithy_http_server::operation::OperationShapeExt;
  137         -
        use ::aws_smithy_http_server::plugin::Plugin;
  138         -
        let svc = crate::operation_shape::ContentTypeParameters::from_service(service);
  139         -
        let svc = self.model_plugin.apply(svc);
  140         -
        let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
  141         -
            .apply(svc);
  142         -
        let svc = self.http_plugin.apply(svc);
  143         -
        self.content_type_parameters_custom(svc)
  144         -
    }
  145         -
  146         -
    /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) to a custom [`Service`](tower::Service).
  147         -
    /// not constrained by the Smithy contract.
  148         -
    fn content_type_parameters_custom<S>(mut self, svc: S) -> Self
  149         -
    where
  150         -
        S: ::tower::Service<
  151         -
                ::http::Request<Body>,
  152         -
                Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  153         -
                Error = ::std::convert::Infallible,
  154         -
            > + Clone
  155         -
            + Send
  156         -
            + 'static,
  157         -
        S::Future: Send + 'static,
  158         -
    {
  159         -
        self.content_type_parameters = Some(::aws_smithy_http_server::routing::Route::new(svc));
  160         -
        self
  161         -
    }
  162         -
}
  163         -
  164         -
impl<Body, L, HttpPl, ModelPl> RestXmlExtrasBuilder<Body, L, HttpPl, ModelPl> {
  165         -
    /// Constructs a [`RestXmlExtras`] from the arguments provided to the builder.
  166         -
    ///
  167         -
    /// Forgetting to register a handler for one or more operations will result in an error.
  168         -
    ///
  169         -
    /// Check out [`RestXmlExtrasBuilder::build_unchecked`] if you'd prefer the service to return status code 500 when an
  170         -
    /// unspecified route is requested.
  171         -
    pub fn build(
  172         -
        self,
  173         -
    ) -> Result<
  174         -
        RestXmlExtras<
  175         -
            ::aws_smithy_http_server::routing::RoutingService<
  176         -
                ::aws_smithy_http_server::protocol::rest::router::RestRouter<L::Service>,
  177         -
                ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  178         -
            >,
  179         -
        >,
  180         -
        MissingOperationsError,
  181         -
    >
  182         -
    where
  183         -
        L: ::tower::Layer<::aws_smithy_http_server::routing::Route<Body>>,
  184         -
    {
  185         -
        let router = {
  186         -
            use ::aws_smithy_http_server::operation::OperationShape;
  187         -
            let mut missing_operation_names = std::collections::HashMap::new();
  188         -
            if self.content_type_parameters.is_none() {
  189         -
                missing_operation_names.insert(
  190         -
                    crate::operation_shape::ContentTypeParameters::ID,
  191         -
                    ".content_type_parameters()",
  192         -
                );
  193         -
            }
  194         -
            if !missing_operation_names.is_empty() {
  195         -
                return Err(MissingOperationsError {
  196         -
                    operation_names2setter_methods: missing_operation_names,
  197         -
                });
  198         -
            }
  199         -
            let unexpected_error_msg = "this should never panic since we are supposed to check beforehand that a handler has been registered for this operation; please file a bug report under https://github.com/smithy-lang/smithy-rs/issues";
  200         -
  201         -
            ::aws_smithy_http_server::protocol::rest::router::RestRouter::from_iter([(
  202         -
                request_specs::content_type_parameters(),
  203         -
                self.content_type_parameters.expect(unexpected_error_msg),
  204         -
            )])
  205         -
        };
  206         -
        let svc = ::aws_smithy_http_server::routing::RoutingService::new(router);
  207         -
        let svc = svc.map(|s| s.layer(self.layer));
  208         -
        Ok(RestXmlExtras { svc })
  209         -
    }
  210         -
  211         -
    /// Constructs a [`RestXmlExtras`] from the arguments provided to the builder.
  212         -
    /// Operations without a handler default to returning 500 Internal Server Error to the caller.
  213         -
    ///
  214         -
    /// Check out [`RestXmlExtrasBuilder::build`] if you'd prefer the builder to fail if one or more operations do
  215         -
    /// not have a registered handler.
  216         -
    pub fn build_unchecked(self) -> RestXmlExtras<L::Service>
  217         -
    where
  218         -
        Body: Send + 'static,
  219         -
        L: ::tower::Layer<
  220         -
            ::aws_smithy_http_server::routing::RoutingService<
  221         -
                ::aws_smithy_http_server::protocol::rest::router::RestRouter<
  222         -
                    ::aws_smithy_http_server::routing::Route<Body>,
  223         -
                >,
  224         -
                ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  225         -
            >,
  226         -
        >,
  227         -
    {
  228         -
        let router = ::aws_smithy_http_server::protocol::rest::router::RestRouter::from_iter([(
  229         -
            request_specs::content_type_parameters(),
  230         -
            self.content_type_parameters.unwrap_or_else(|| {
  231         -
                let svc = ::aws_smithy_http_server::operation::MissingFailure::<
  232         -
                    ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  233         -
                >::default();
  234         -
                ::aws_smithy_http_server::routing::Route::new(svc)
  235         -
            }),
  236         -
        )]);
  237         -
        let svc = self
  238         -
            .layer
  239         -
            .layer(::aws_smithy_http_server::routing::RoutingService::new(
  240         -
                router,
  241         -
            ));
  242         -
        RestXmlExtras { svc }
  243         -
    }
  244         -
}
  245         -
  246         -
/// The error encountered when calling the [`RestXmlExtrasBuilder::build`] method if one or more operation handlers are not
  247         -
/// specified.
  248         -
#[derive(Debug)]
  249         -
pub struct MissingOperationsError {
  250         -
    operation_names2setter_methods:
  251         -
        std::collections::HashMap<::aws_smithy_http_server::shape_id::ShapeId, &'static str>,
  252         -
}
  253         -
  254         -
impl std::fmt::Display for MissingOperationsError {
  255         -
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  256         -
        write!(
  257         -
            f,
  258         -
            "You must specify a handler for all operations attached to `RestXmlExtras`.\n\
  259         -
                            We are missing handlers for the following operations:\n",
  260         -
        )?;
  261         -
        for operation_name in self.operation_names2setter_methods.keys() {
  262         -
            writeln!(f, "- {}", operation_name.absolute())?;
  263         -
        }
  264         -
  265         -
        writeln!(f, "\nUse the dedicated methods on `RestXmlExtrasBuilder` to register the missing handlers:")?;
  266         -
        for setter_name in self.operation_names2setter_methods.values() {
  267         -
            writeln!(f, "- {}", setter_name)?;
  268         -
        }
  269         -
        Ok(())
  270         -
    }
  271         -
}
  272         -
  273         -
impl std::error::Error for MissingOperationsError {}
  274         -
  275         -
mod request_specs {
  276         -
    pub(super) fn content_type_parameters(
  277         -
    ) -> ::aws_smithy_http_server::routing::request_spec::RequestSpec {
  278         -
        ::aws_smithy_http_server::routing::request_spec::RequestSpec::new(
  279         -
                    ::http::Method::PUT,
  280         -
                    ::aws_smithy_http_server::routing::request_spec::UriSpec::new(
  281         -
                        ::aws_smithy_http_server::routing::request_spec::PathAndQuerySpec::new(
  282         -
                            ::aws_smithy_http_server::routing::request_spec::PathSpec::from_vector_unchecked(vec![
  283         -
    ::aws_smithy_http_server::routing::request_spec::PathSegment::Literal(String::from("ContentTypeParameters")),
  284         -
]),
  285         -
                            ::aws_smithy_http_server::routing::request_spec::QuerySpec::from_vector_unchecked(vec![
  286         -
])
  287         -
                        )
  288         -
                    ),
  289         -
                )
  290         -
    }
  291         -
}
  292         -
  293         -
/// A REST XML service that sends XML requests and responses.
  294         -
///
  295         -
/// See the [root](crate) documentation for more information.
  296         -
#[derive(Clone)]
  297         -
pub struct RestXmlExtras<
  298         -
    S = ::aws_smithy_http_server::routing::RoutingService<
  299         -
        ::aws_smithy_http_server::protocol::rest::router::RestRouter<
  300         -
            ::aws_smithy_http_server::routing::Route<::aws_smithy_http_server::body::BoxBody>,
  301         -
        >,
  302         -
        ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  303         -
    >,
  304         -
> {
  305         -
    // This is the router wrapped by layers.
  306         -
    svc: S,
  307         -
}
  308         -
  309         -
impl RestXmlExtras<()> {
  310         -
    /// Constructs a builder for [`RestXmlExtras`].
  311         -
    /// You must specify a configuration object holding any plugins and layers that should be applied
  312         -
    /// to the operations in this service.
  313         -
    pub fn builder<
  314         -
        Body,
  315         -
        L,
  316         -
        HttpPl: ::aws_smithy_http_server::plugin::HttpMarker,
  317         -
        ModelPl: ::aws_smithy_http_server::plugin::ModelMarker,
  318         -
    >(
  319         -
        config: RestXmlExtrasConfig<L, HttpPl, ModelPl>,
  320         -
    ) -> RestXmlExtrasBuilder<Body, L, HttpPl, ModelPl> {
  321         -
        RestXmlExtrasBuilder {
  322         -
            content_type_parameters: None,
  323         -
            layer: config.layers,
  324         -
            http_plugin: config.http_plugins,
  325         -
            model_plugin: config.model_plugins,
  326         -
        }
  327         -
    }
  328         -
  329         -
    /// Constructs a builder for [`RestXmlExtras`].
  330         -
    /// You must specify what plugins should be applied to the operations in this service.
  331         -
    ///
  332         -
    /// Use [`RestXmlExtras::builder_without_plugins`] if you don't need to apply plugins.
  333         -
    ///
  334         -
    /// Check out [`HttpPlugins`](::aws_smithy_http_server::plugin::HttpPlugins) and
  335         -
    /// [`ModelPlugins`](::aws_smithy_http_server::plugin::ModelPlugins) if you need to apply
  336         -
    /// multiple plugins.
  337         -
    #[deprecated(
  338         -
        since = "0.57.0",
  339         -
        note = "please use the `builder` constructor and register plugins on the `RestXmlExtrasConfig` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
  340         -
    )]
  341         -
    pub fn builder_with_plugins<
  342         -
        Body,
  343         -
        HttpPl: ::aws_smithy_http_server::plugin::HttpMarker,
  344         -
        ModelPl: ::aws_smithy_http_server::plugin::ModelMarker,
  345         -
    >(
  346         -
        http_plugin: HttpPl,
  347         -
        model_plugin: ModelPl,
  348         -
    ) -> RestXmlExtrasBuilder<Body, ::tower::layer::util::Identity, HttpPl, ModelPl> {
  349         -
        RestXmlExtrasBuilder {
  350         -
            content_type_parameters: None,
  351         -
            layer: ::tower::layer::util::Identity::new(),
  352         -
            http_plugin,
  353         -
            model_plugin,
  354         -
        }
  355         -
    }
  356         -
  357         -
    /// Constructs a builder for [`RestXmlExtras`].
  358         -
    ///
  359         -
    /// Use [`RestXmlExtras::builder_with_plugins`] if you need to specify plugins.
  360         -
    #[deprecated(
  361         -
        since = "0.57.0",
  362         -
        note = "please use the `builder` constructor instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
  363         -
    )]
  364         -
    pub fn builder_without_plugins<Body>() -> RestXmlExtrasBuilder<
  365         -
        Body,
  366         -
        ::tower::layer::util::Identity,
  367         -
        ::aws_smithy_http_server::plugin::IdentityPlugin,
  368         -
        ::aws_smithy_http_server::plugin::IdentityPlugin,
  369         -
    > {
  370         -
        Self::builder_with_plugins(
  371         -
            ::aws_smithy_http_server::plugin::IdentityPlugin,
  372         -
            ::aws_smithy_http_server::plugin::IdentityPlugin,
  373         -
        )
  374         -
    }
  375         -
}
  376         -
  377         -
impl<S> RestXmlExtras<S> {
  378         -
    /// Converts [`RestXmlExtras`] into a [`MakeService`](tower::make::MakeService).
  379         -
    pub fn into_make_service(self) -> ::aws_smithy_http_server::routing::IntoMakeService<Self> {
  380         -
        ::aws_smithy_http_server::routing::IntoMakeService::new(self)
  381         -
    }
  382         -
  383         -
    /// Converts [`RestXmlExtras`] into a [`MakeService`](tower::make::MakeService) with [`ConnectInfo`](::aws_smithy_http_server::request::connect_info::ConnectInfo).
  384         -
    pub fn into_make_service_with_connect_info<C>(
  385         -
        self,
  386         -
    ) -> ::aws_smithy_http_server::routing::IntoMakeServiceWithConnectInfo<Self, C> {
  387         -
        ::aws_smithy_http_server::routing::IntoMakeServiceWithConnectInfo::new(self)
  388         -
    }
  389         -
}
  390         -
  391         -
impl<S>
  392         -
    RestXmlExtras<
  393         -
        ::aws_smithy_http_server::routing::RoutingService<
  394         -
            ::aws_smithy_http_server::protocol::rest::router::RestRouter<S>,
  395         -
            ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  396         -
        >,
  397         -
    >
  398         -
{
  399         -
    /// Applies a [`Layer`](::tower::Layer) uniformly to all routes.
  400         -
    #[deprecated(
  401         -
        since = "0.57.0",
  402         -
        note = "please add layers to the `RestXmlExtrasConfig` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
  403         -
    )]
  404         -
    pub fn layer<L>(
  405         -
        self,
  406         -
        layer: &L,
  407         -
    ) -> RestXmlExtras<
  408         -
        ::aws_smithy_http_server::routing::RoutingService<
  409         -
            ::aws_smithy_http_server::protocol::rest::router::RestRouter<L::Service>,
  410         -
            ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  411         -
        >,
  412         -
    >
  413         -
    where
  414         -
        L: ::tower::Layer<S>,
  415         -
    {
  416         -
        RestXmlExtras {
  417         -
            svc: self.svc.map(|s| s.layer(layer)),
  418         -
        }
  419         -
    }
  420         -
  421         -
    /// Applies [`Route::new`](::aws_smithy_http_server::routing::Route::new) to all routes.
  422         -
    ///
  423         -
    /// This has the effect of erasing all types accumulated via layers.
  424         -
    pub fn boxed<B>(
  425         -
        self,
  426         -
    ) -> RestXmlExtras<
  427         -
        ::aws_smithy_http_server::routing::RoutingService<
  428         -
            ::aws_smithy_http_server::protocol::rest::router::RestRouter<
  429         -
                ::aws_smithy_http_server::routing::Route<B>,
  430         -
            >,
  431         -
            ::aws_smithy_http_server::protocol::rest_xml::RestXml,
  432         -
        >,
  433         -
    >
  434         -
    where
  435         -
        S: ::tower::Service<
  436         -
            ::http::Request<B>,
  437         -
            Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
  438         -
            Error = std::convert::Infallible,
  439         -
        >,
  440         -
        S: Clone + Send + 'static,
  441         -
        S::Future: Send + 'static,
  442         -
    {
  443         -
        self.layer(&::tower::layer::layer_fn(
  444         -
            ::aws_smithy_http_server::routing::Route::new,
  445         -
        ))
  446         -
    }
  447         -
}
  448         -
  449         -
impl<S, R> ::tower::Service<R> for RestXmlExtras<S>
  450         -
where
  451         -
    S: ::tower::Service<R>,
  452         -
{
  453         -
    type Response = S::Response;
  454         -
    type Error = S::Error;
  455         -
    type Future = S::Future;
  456         -
  457         -
    fn poll_ready(
  458         -
        &mut self,
  459         -
        cx: &mut std::task::Context,
  460         -
    ) -> std::task::Poll<Result<(), Self::Error>> {
  461         -
        self.svc.poll_ready(cx)
  462         -
    }
  463         -
  464         -
    fn call(&mut self, request: R) -> Self::Future {
  465         -
        self.svc.call(request)
  466         -
    }
  467         -
}
  468         -
  469         -
/// An enumeration of all [operations](https://smithy.io/2.0/spec/service-types.html#operation) in RestXmlExtras.
  470         -
#[allow(clippy::enum_variant_names)]
  471         -
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
  472         -
pub enum Operation {
  473         -
    ContentTypeParameters,
  474         -
}
  475         -
  476         -
impl Operation {
  477         -
    /// Returns the [operations](https://smithy.io/2.0/spec/service-types.html#operation) [`ShapeId`](::aws_smithy_http_server::shape_id::ShapeId).
  478         -
    pub fn shape_id(&self) -> ::aws_smithy_http_server::shape_id::ShapeId {
  479         -
        match self {
  480         -
            Operation::ContentTypeParameters => ::aws_smithy_http_server::shape_id::ShapeId::new(
  481         -
                "aws.protocoltests.restxml#ContentTypeParameters",
  482         -
                "aws.protocoltests.restxml",
  483         -
                "ContentTypeParameters",
  484         -
            ),
  485         -
        }
  486         -
    }
  487         -
}
  488         -
impl<L>
  489         -
    ::aws_smithy_http_server::service::ContainsOperation<
  490         -
        crate::operation_shape::ContentTypeParameters,
  491         -
    > for RestXmlExtras<L>
  492         -
{
  493         -
    const VALUE: Operation = Operation::ContentTypeParameters;
  494         -
}
  495         -
  496         -
impl<S> ::aws_smithy_http_server::service::ServiceShape for RestXmlExtras<S> {
  497         -
    const ID: ::aws_smithy_http_server::shape_id::ShapeId =
  498         -
        ::aws_smithy_http_server::shape_id::ShapeId::new(
  499         -
            "aws.protocoltests.restxml#RestXmlExtras",
  500         -
            "aws.protocoltests.restxml",
  501         -
            "RestXmlExtras",
  502         -
        );
  503         -
  504         -
    const VERSION: Option<&'static str> = Some("2024-04-15");
  505         -
  506         -
    type Protocol = ::aws_smithy_http_server::protocol::rest_xml::RestXml;
  507         -
  508         -
    type Operations = Operation;
  509         -
}
  510         -
/// Configuration for the [`RestXmlExtras`]. This is the central place where to register and
  511         -
/// configure [`::tower::Layer`]s, HTTP plugins, and model plugins.
  512         -
///
  513         -
/// ```rust,no_run
  514         -
/// # use rest_xml_extras::RestXmlExtrasConfig;
  515         -
/// # use ::aws_smithy_http_server::plugin::IdentityPlugin;
  516         -
/// # use ::tower::layer::util::Identity;
  517         -
/// # let authentication_plugin = IdentityPlugin;
  518         -
/// # let authorization_plugin = IdentityPlugin;
  519         -
/// # let server_request_id_provider_layer = Identity::new();
  520         -
/// let config = RestXmlExtrasConfig::builder()
  521         -
///     // Layers get executed first...
  522         -
///     .layer(server_request_id_provider_layer)
  523         -
///     // ...then HTTP plugins...
  524         -
///     .http_plugin(authentication_plugin)
  525         -
///     // ...and right after deserialization, model plugins.
  526         -
///     .model_plugin(authorization_plugin)
  527         -
///     .build();
  528         -
/// ```
  529         -
///
  530         -
/// See the [`plugin`] system for details.
  531         -
///
  532         -
/// [`plugin`]: ::aws_smithy_http_server::plugin
  533         -
#[derive(::std::fmt::Debug)]
  534         -
pub struct RestXmlExtrasConfig<L, H, M> {
  535         -
    layers: L,
  536         -
    http_plugins: H,
  537         -
    model_plugins: M,
  538         -
}
  539         -
  540         -
impl RestXmlExtrasConfig<(), (), ()> {
  541         -
    /// Returns a builder to construct the configuration.
  542         -
    pub fn builder() -> RestXmlExtrasConfigBuilder<
  543         -
        ::tower::layer::util::Identity,
  544         -
        ::aws_smithy_http_server::plugin::IdentityPlugin,
  545         -
        ::aws_smithy_http_server::plugin::IdentityPlugin,
  546         -
    > {
  547         -
        RestXmlExtrasConfigBuilder {
  548         -
            layers: ::tower::layer::util::Identity::new(),
  549         -
            http_plugins: ::aws_smithy_http_server::plugin::IdentityPlugin,
  550         -
            model_plugins: ::aws_smithy_http_server::plugin::IdentityPlugin,
  551         -
        }
  552         -
    }
  553         -
}
  554         -
  555         -
/// Builder returned by [`RestXmlExtrasConfig::builder()`].
  556         -
#[derive(::std::fmt::Debug)]
  557         -
pub struct RestXmlExtrasConfigBuilder<L, H, M> {
  558         -
    pub(crate) layers: L,
  559         -
    pub(crate) http_plugins: H,
  560         -
    pub(crate) model_plugins: M,
  561         -
}
  562         -
  563         -
impl<L, H, M> RestXmlExtrasConfigBuilder<L, H, M> {
  564         -
    /// Add a [`::tower::Layer`] to the service.
  565         -
    pub fn layer<NewLayer>(
  566         -
        self,
  567         -
        layer: NewLayer,
  568         -
    ) -> RestXmlExtrasConfigBuilder<::tower::layer::util::Stack<NewLayer, L>, H, M> {
  569         -
        RestXmlExtrasConfigBuilder {
  570         -
            layers: ::tower::layer::util::Stack::new(layer, self.layers),
  571         -
            http_plugins: self.http_plugins,
  572         -
            model_plugins: self.model_plugins,
  573         -
        }
  574         -
    }
  575         -
  576         -
    /// Add a HTTP [plugin] to the service.
  577         -
    ///
  578         -
    /// [plugin]: ::aws_smithy_http_server::plugin
  579         -
    // We eagerly require `NewPlugin: HttpMarker`, despite not really needing it, because compiler
  580         -
    // errors get _substantially_ better if the user makes a mistake.
  581         -
    pub fn http_plugin<NewPlugin: ::aws_smithy_http_server::plugin::HttpMarker>(
  582         -
        self,
  583         -
        http_plugin: NewPlugin,
  584         -
    ) -> RestXmlExtrasConfigBuilder<L, ::aws_smithy_http_server::plugin::PluginStack<NewPlugin, H>, M>
  585         -
    {
  586         -
        RestXmlExtrasConfigBuilder {
  587         -
            layers: self.layers,
  588         -
            http_plugins: ::aws_smithy_http_server::plugin::PluginStack::new(
  589         -
                http_plugin,
  590         -
                self.http_plugins,
  591         -
            ),
  592         -
            model_plugins: self.model_plugins,
  593         -
        }
  594         -
    }
  595         -
  596         -
    /// Add a model [plugin] to the service.
  597         -
    ///
  598         -
    /// [plugin]: ::aws_smithy_http_server::plugin
  599         -
    // We eagerly require `NewPlugin: ModelMarker`, despite not really needing it, because compiler
  600         -
    // errors get _substantially_ better if the user makes a mistake.
  601         -
    pub fn model_plugin<NewPlugin: ::aws_smithy_http_server::plugin::ModelMarker>(
  602         -
        self,
  603         -
        model_plugin: NewPlugin,
  604         -
    ) -> RestXmlExtrasConfigBuilder<L, H, ::aws_smithy_http_server::plugin::PluginStack<NewPlugin, M>>
  605         -
    {
  606         -
        RestXmlExtrasConfigBuilder {
  607         -
            layers: self.layers,
  608         -
            http_plugins: self.http_plugins,
  609         -
            model_plugins: ::aws_smithy_http_server::plugin::PluginStack::new(
  610         -
                model_plugin,
  611         -
                self.model_plugins,
  612         -
            ),
  613         -
        }
  614         -
    }
  615         -
  616         -
    /// Build the configuration.
  617         -
    pub fn build(self) -> super::RestXmlExtrasConfig<L, H, M> {
  618         -
        super::RestXmlExtrasConfig {
  619         -
            layers: self.layers,
  620         -
            http_plugins: self.http_plugins,
  621         -
            model_plugins: self.model_plugins,
  622         -
        }
  623         -
    }
  624         -
}
  625         -
/// A macro to help with scoping [plugins](::aws_smithy_http_server::plugin) to a subset of all operations.
  626         -
///
  627         -
/// In contrast to [`aws_smithy_http_server::scope`](::aws_smithy_http_server::scope), this macro has knowledge
  628         -
/// of the service and any operations _not_ specified will be placed in the opposing group.
  629         -
///
  630         -
/// # Example
  631         -
///
  632         -
/// ```rust
  633         -
/// scope! {
  634         -
///     /// Includes [`ContentTypeParameters`], excluding all other operations.
  635         -
///     struct ScopeA {
  636         -
///         includes: [ContentTypeParameters]
  637         -
///     }
  638         -
/// }
  639         -
///
  640         -
/// scope! {
  641         -
///     /// Excludes [`ContentTypeParameters`], excluding all other operations.
  642         -
///     struct ScopeB {
  643         -
///         excludes: [ContentTypeParameters]
  644         -
///     }
  645         -
/// }
  646         -
///
  647         -
/// # use ::aws_smithy_http_server::plugin::{Plugin, Scoped};
  648         -
/// # use rest_xml_extras::scope;
  649         -
/// # struct MockPlugin;
  650         -
/// # impl<S, Op, T> Plugin<S, Op, T> for MockPlugin { type Output = u32; fn apply(&self, input: T) -> u32 { 3 } }
  651         -
/// # let scoped_a = Scoped::new::<ScopeA>(MockPlugin);
  652         -
/// # let scoped_b = Scoped::new::<ScopeB>(MockPlugin);
  653         -
/// # let a = Plugin::<(), rest_xml_extras::operation_shape::ContentTypeParameters, u64>::apply(&scoped_a, 6);
  654         -
/// # let b = Plugin::<(), rest_xml_extras::operation_shape::ContentTypeParameters, u64>::apply(&scoped_b, 6);
  655         -
/// # assert_eq!(a, 3_u32);
  656         -
/// # assert_eq!(b, 6_u64);
  657         -
/// ```
  658         -
#[macro_export]
  659         -
macro_rules! scope {
  660         -
                    // Completed, render impls
  661         -
                    (@ $ name: ident, $ contains: ident () ($($ temp: ident)*) ($($ not_member: ident)*)) => {
  662         -
                        $(
  663         -
                            impl ::aws_smithy_http_server::plugin::scoped::Membership<$ temp> for $ name {
  664         -
                                type Contains = ::aws_smithy_http_server::plugin::scoped::$ contains;
  665         -
                            }
  666         -
                        )*
  667         -
                        $(
  668         -
                            impl ::aws_smithy_http_server::plugin::scoped::Membership<$ not_member> for $ name {
  669         -
                                type Contains = ::aws_smithy_http_server::plugin::scoped::$ contains;
  670         -
                            }
  671         -
                        )*
  672         -
                    };
  673         -
                    // All `not_member`s exhausted, move `temp` into `not_member`
  674         -
                    (@ $ name: ident, $ contains: ident ($($ member: ident)*) ($($ temp: ident)*) ()) => {
  675         -
                        scope! { @ $ name, $ contains ($($ member)*) () ($($ temp)*) }
  676         -
                    };
  677         -
  678         -
                        // ContentTypeParameters match found, pop from both `member` and `not_member`
  679         -
                        (@ $ name: ident, $ contains: ident (ContentTypeParameters $($ member: ident)*) ($($ temp: ident)*) (ContentTypeParameters $($ not_member: ident)*)) => {
  680         -
                            scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
  681         -
                        };
  682         -
                        // ContentTypeParameters match not found, pop from `not_member` into `temp` stack
  683         -
                        (@ $ name: ident, $ contains: ident (ContentTypeParameters $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
  684         -
                            scope! { @ $ name, $ contains (ContentTypeParameters $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
  685         -
                        };
  686         -
  687         -
                    (
  688         -
                        $(#[$ attrs:meta])*
  689         -
                        $ vis:vis struct $ name:ident {
  690         -
                            includes: [$($ include:ident),*]
  691         -
                        }
  692         -
                    ) => {
  693         -
                        use $ crate::operation_shape::*;
  694         -
                        ::aws_smithy_http_server::scope! {
  695         -
                            $(#[$ attrs])*
  696         -
                            $ vis struct $ name {
  697         -
                                includes: [$($ include),*],
  698         -
                                excludes: []
  699         -
                            }
  700         -
                        }
  701         -
                        scope! { @ $ name, False ($($ include)*) () (ContentTypeParameters) }
  702         -
                    };
  703         -
                    (
  704         -
                        $(#[$ attrs:meta])*
  705         -
                        $ vis:vis struct $ name:ident {
  706         -
                            excludes: [$($ exclude:ident),*]
  707         -
                        }
  708         -
                    ) => {
  709         -
                        use $ crate::operation_shape::*;
  710         -
  711         -
                        ::aws_smithy_http_server::scope! {
  712         -
                            $(#[$ attrs])*
  713         -
                            $ vis struct $ name {
  714         -
                                includes: [],
  715         -
                                excludes: [$($ exclude),*]
  716         -
                            }
  717         -
                        }
  718         -
                        scope! { @ $ name, True ($($ exclude)*) () (ContentTypeParameters) }
  719         -
                    };
  720         -
                }