Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5

Files changed:

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

@@ -0,1 +0,204 @@
           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  +
    /// [`MalformedUniqueItemsInput`](crate::input::MalformedUniqueItemsInput) using modelled bindings.
           5  +
    pub struct MalformedUniqueItemsInputFuture {
           6  +
        inner: std::pin::Pin<Box<dyn std::future::Future<Output = Result<crate::input::MalformedUniqueItemsInput, ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError>> + Send>>
           7  +
    }
           8  +
}
           9  +
          10  +
impl std::future::Future for MalformedUniqueItemsInputFuture {
          11  +
    type Output = Result<
          12  +
        crate::input::MalformedUniqueItemsInput,
          13  +
        ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::rest_json_1::RestJson1,
          28  +
        B,
          29  +
    > for crate::input::MalformedUniqueItemsInput
          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::rest_json_1::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::rest_json_1::runtime_error::RuntimeError;
          40  +
    type Future = MalformedUniqueItemsInputFuture;
          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_JSON,
          47  +
            ) {
          48  +
                return Err(::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::NotAcceptable);
          49  +
            }
          50  +
            crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items_http_request(request)
          51  +
                            .await
          52  +
        };
          53  +
        use ::futures_util::future::TryFutureExt;
          54  +
        let fut = fut.map_err(|e: ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection| {
          55  +
                        ::tracing::debug!(error = %e, "failed to deserialize request");
          56  +
                        ::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e)
          57  +
                    });
          58  +
        MalformedUniqueItemsInputFuture {
          59  +
            inner: Box::pin(fut),
          60  +
        }
          61  +
    }
          62  +
}
          63  +
impl
          64  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
          65  +
        ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
          66  +
    > for crate::output::MalformedUniqueItemsOutput
          67  +
{
          68  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
          69  +
        match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_response(self) {
          70  +
                        Ok(response) => response,
          71  +
                        Err(e) => {
          72  +
                            ::tracing::error!(error = %e, "failed to serialize response");
          73  +
                            ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
          74  +
                        }
          75  +
                    }
          76  +
    }
          77  +
}
          78  +
impl
          79  +
    ::aws_smithy_legacy_http_server::response::IntoResponse<
          80  +
        ::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1,
          81  +
    > for crate::error::MalformedUniqueItemsError
          82  +
{
          83  +
    fn into_response(self) -> ::aws_smithy_legacy_http_server::response::Response {
          84  +
        match crate::protocol_serde::shape_malformed_unique_items::ser_malformed_unique_items_http_error(&self) {
          85  +
            Ok(mut response) => {
          86  +
                response.extensions_mut().insert(::aws_smithy_legacy_http_server::extension::ModeledErrorExtension::new(self.name()));
          87  +
                response
          88  +
            },
          89  +
            Err(e) => {
          90  +
                ::tracing::error!(error = %e, "failed to serialize response");
          91  +
                ::aws_smithy_legacy_http_server::response::IntoResponse::<::aws_smithy_legacy_http_server::protocol::rest_json_1::RestJson1>::into_response(::aws_smithy_legacy_http_server::protocol::rest_json_1::runtime_error::RuntimeError::from(e))
          92  +
            }
          93  +
        }
          94  +
    }
          95  +
}
          96  +
          97  +
#[allow(unreachable_code, unused_variables)]
          98  +
#[cfg(test)]
          99  +
mod malformed_unique_items_test {
         100  +
         101  +
    /// When the list has duplicated items, the response should be a 400
         102  +
    /// ValidationException.
         103  +
    /// Test ID: RestJsonMalformedUniqueItemsDuplicateItems
         104  +
    #[::tokio::test]
         105  +
    #[::tracing_test::traced_test]
         106  +
    async fn rest_json_malformed_unique_items_duplicate_items_malformed_request() {
         107  +
        {
         108  +
            #[allow(unused_mut)]
         109  +
            let mut http_request = ::http::Request::builder()
         110  +
                .uri("/MalformedUniqueItems")
         111  +
                .method("POST")
         112  +
                .header("content-type", "application/json")
         113  +
                .body(::aws_smithy_legacy_http_server::body::Body::from(
         114  +
                    ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
         115  +
                        "{ \"set\" : [\"a\", \"a\", \"b\", \"c\"] }".as_bytes(),
         116  +
                        ::aws_smithy_protocol_test::MediaType::from("unknown"),
         117  +
                    )),
         118  +
                ))
         119  +
                .unwrap();
         120  +
            #[allow(unused_mut)]
         121  +
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
         122  +
            let config = crate::service::UniqueItemsServiceConfig::builder().build();
         123  +
            let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
         124  +
                            .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
         125  +
                                let sender = sender.clone();
         126  +
                                async move {
         127  +
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
         128  +
                                    sender.send(()).await.expect("receiver dropped early");
         129  +
                                    result
         130  +
                                }
         131  +
                            })
         132  +
                            .build_unchecked();
         133  +
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
         134  +
                .await
         135  +
                .expect("unable to make an HTTP request");
         136  +
            ::pretty_assertions::assert_eq!(
         137  +
                ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
         138  +
                http_response.status()
         139  +
            );
         140  +
            let expected_headers = [("x-amzn-errortype", "ValidationException")];
         141  +
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
         142  +
                http_response.headers(),
         143  +
                expected_headers,
         144  +
            ));
         145  +
            let body = ::hyper::body::to_bytes(http_response.into_body())
         146  +
                .await
         147  +
                .expect("unable to extract body to bytes");
         148  +
            ::aws_smithy_protocol_test::assert_ok(
         149  +
            ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\",\n  \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\", \"path\": \"/set\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
         150  +
            );
         151  +
        }
         152  +
    }
         153  +
         154  +
    /// When the list has duplicated blobs, the response should be a 400
         155  +
    /// ValidationException.
         156  +
    /// Test ID: RestJsonMalformedUniqueItemsDuplicateBlobs
         157  +
    #[::tokio::test]
         158  +
    #[::tracing_test::traced_test]
         159  +
    async fn rest_json_malformed_unique_items_duplicate_blobs_malformed_request() {
         160  +
        {
         161  +
            #[allow(unused_mut)]
         162  +
                        let mut http_request = ::http::Request::builder()
         163  +
                            .uri("/MalformedUniqueItems")
         164  +
                            .method("POST")
         165  +
            .header("content-type", "application/json")
         166  +
            .body(::aws_smithy_legacy_http_server::body::Body::from(
         167  +
                            ::bytes::Bytes::copy_from_slice(
         168  +
                                &::aws_smithy_protocol_test::decode_body_data("{ \"complexSet\" : [{\"foo\": true, \"blob\": \"YmxvYg==\"}, {\"foo\": true, \"blob\": \"b3RoZXJibG9i\"}, {\"foo\": true, \"blob\": \"YmxvYg==\"}] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
         169  +
                            )
         170  +
                            )).unwrap();
         171  +
            #[allow(unused_mut)]
         172  +
            let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
         173  +
            let config = crate::service::UniqueItemsServiceConfig::builder().build();
         174  +
            let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
         175  +
                            .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
         176  +
                                let sender = sender.clone();
         177  +
                                async move {
         178  +
                                    let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
         179  +
                                    sender.send(()).await.expect("receiver dropped early");
         180  +
                                    result
         181  +
                                }
         182  +
                            })
         183  +
                            .build_unchecked();
         184  +
            let http_response = ::tower::ServiceExt::oneshot(service, http_request)
         185  +
                .await
         186  +
                .expect("unable to make an HTTP request");
         187  +
            ::pretty_assertions::assert_eq!(
         188  +
                ::http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
         189  +
                http_response.status()
         190  +
            );
         191  +
            let expected_headers = [("x-amzn-errortype", "ValidationException")];
         192  +
            ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
         193  +
                http_response.headers(),
         194  +
                expected_headers,
         195  +
            ));
         196  +
            let body = ::hyper::body::to_bytes(http_response.into_body())
         197  +
                .await
         198  +
                .expect("unable to extract body to bytes");
         199  +
            ::aws_smithy_protocol_test::assert_ok(
         200  +
            ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\",\n  \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\", \"path\": \"/complexSet\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
         201  +
            );
         202  +
        }
         203  +
    }
         204  +
}

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

@@ -0,1 +0,40 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(missing_docs)] // documentation missing in model
           3  +
pub struct MalformedUniqueItems;
           4  +
           5  +
impl ::aws_smithy_legacy_http_server::operation::OperationShape for MalformedUniqueItems {
           6  +
    const ID: ::aws_smithy_legacy_http_server::shape_id::ShapeId =
           7  +
        ::aws_smithy_legacy_http_server::shape_id::ShapeId::new(
           8  +
            "com.amazonaws.constraints#MalformedUniqueItems",
           9  +
            "com.amazonaws.constraints",
          10  +
            "MalformedUniqueItems",
          11  +
        );
          12  +
          13  +
    type Input = crate::input::MalformedUniqueItemsInput;
          14  +
    type Output = crate::output::MalformedUniqueItemsOutput;
          15  +
    type Error = crate::error::MalformedUniqueItemsError;
          16  +
}
          17  +
          18  +
impl ::aws_smithy_legacy_http_server::instrumentation::sensitivity::Sensitivity
          19  +
    for MalformedUniqueItems
          20  +
{
          21  +
    type RequestFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt<
          22  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          23  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::uri::MakeUri<
          24  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          25  +
            ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          26  +
        >,
          27  +
    >;
          28  +
    type ResponseFmt = ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt<
          29  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          30  +
        ::aws_smithy_legacy_http_server::instrumentation::MakeIdentity,
          31  +
    >;
          32  +
          33  +
    fn request_fmt() -> Self::RequestFmt {
          34  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::RequestFmt::new()
          35  +
    }
          36  +
          37  +
    fn response_fmt() -> Self::ResponseFmt {
          38  +
        ::aws_smithy_legacy_http_server::instrumentation::sensitivity::ResponseFmt::new()
          39  +
    }
          40  +
}

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

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

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

@@ -0,1 +0,20 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) mod shape_malformed_unique_items;
           3  +
           4  +
pub(crate) fn or_empty_doc(data: &[u8]) -> &[u8] {
           5  +
    if data.is_empty() {
           6  +
        b"{}"
           7  +
    } else {
           8  +
        data
           9  +
    }
          10  +
}
          11  +
          12  +
pub(crate) mod shape_validation_exception;
          13  +
          14  +
pub(crate) mod shape_complex_set;
          15  +
          16  +
pub(crate) mod shape_simple_set;
          17  +
          18  +
pub(crate) mod shape_complex_set_struct;
          19  +
          20  +
pub(crate) mod shape_validation_exception_field;

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

@@ -0,1 +0,53 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_complex_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value =
          28  +
                            crate::protocol_serde::shape_complex_set_struct::de_complex_set_struct(
          29  +
                                tokens,
          30  +
                            )?;
          31  +
                        if let Some(value) = value {
          32  +
                            items.push(value);
          33  +
                        } else {
          34  +
                            return Err(
          35  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          36  +
                                    "dense list cannot contain null values",
          37  +
                                ),
          38  +
                            );
          39  +
                        }
          40  +
                    }
          41  +
                }
          42  +
            }
          43  +
            Ok(Some(
          44  +
                crate::unconstrained::complex_set_unconstrained::ComplexSetUnconstrained(items),
          45  +
            ))
          46  +
        }
          47  +
        _ => Err(
          48  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          49  +
                "expected start array or null",
          50  +
            ),
          51  +
        ),
          52  +
    }
          53  +
}

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

@@ -0,1 +0,60 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_complex_set_struct<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::ComplexSetStruct>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          19  +
            #[allow(unused_mut)]
          20  +
            let mut builder = crate::model::complex_set_struct::Builder::default();
          21  +
            loop {
          22  +
                match tokens.next().transpose()? {
          23  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          24  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          25  +
                        match key.to_unescaped()?.as_ref() {
          26  +
                            "foo" => {
          27  +
                                builder = builder.set_foo(
          28  +
                                    ::aws_smithy_json::deserialize::token::expect_bool_or_null(
          29  +
                                        tokens.next(),
          30  +
                                    )?,
          31  +
                                );
          32  +
                            }
          33  +
                            "blob" => {
          34  +
                                builder = builder.set_blob(
          35  +
                                    ::aws_smithy_json::deserialize::token::expect_blob_or_null(
          36  +
                                        tokens.next(),
          37  +
                                    )?,
          38  +
                                );
          39  +
                            }
          40  +
                            _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          41  +
                        }
          42  +
                    }
          43  +
                    other => {
          44  +
                        return Err(
          45  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          46  +
                                format!("expected object key or end object, found: {other:?}"),
          47  +
                            ),
          48  +
                        )
          49  +
                    }
          50  +
                }
          51  +
            }
          52  +
            Ok(Some(builder.build()))
          53  +
        }
          54  +
        _ => Err(
          55  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          56  +
                "expected start object or null",
          57  +
            ),
          58  +
        ),
          59  +
    }
          60  +
}

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

@@ -0,1 +0,150 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_malformed_unique_items_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::MalformedUniqueItemsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
           8  +
>
           9  +
where
          10  +
    B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
          11  +
    B::Data: Send,
          12  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
          13  +
        From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
          14  +
{
          15  +
    Ok({
          16  +
        #[allow(unused_mut)]
          17  +
        let mut input = crate::input::malformed_unique_items_input::Builder::default();
          18  +
        #[allow(unused_variables)]
          19  +
        let ::aws_smithy_runtime_api::http::RequestParts {
          20  +
            uri, headers, body, ..
          21  +
        } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
          22  +
        let bytes = ::hyper::body::to_bytes(body).await?;
          23  +
        if !bytes.is_empty() {
          24  +
            ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
          25  +
                &headers,
          26  +
                Some("application/json"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_malformed_unique_items::de_malformed_unique_items(
          29  +
                bytes.as_ref(),
          30  +
                input,
          31  +
            )?;
          32  +
        }
          33  +
        input.build()?
          34  +
    })
          35  +
}
          36  +
          37  +
#[allow(clippy::unnecessary_wraps)]
          38  +
pub fn ser_malformed_unique_items_http_response(
          39  +
    #[allow(unused_variables)] output: crate::output::MalformedUniqueItemsOutput,
          40  +
) -> std::result::Result<
          41  +
    ::aws_smithy_legacy_http_server::response::Response,
          42  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          43  +
> {
          44  +
    Ok({
          45  +
        #[allow(unused_mut)]
          46  +
        let mut builder = ::http::Response::builder();
          47  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          48  +
            builder,
          49  +
            ::http::header::CONTENT_TYPE,
          50  +
            "application/json",
          51  +
        );
          52  +
        let http_status: u16 = 200;
          53  +
        builder = builder.status(http_status);
          54  +
        let payload = "";
          55  +
        let content_length = payload.len();
          56  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          57  +
            builder,
          58  +
            ::http::header::CONTENT_LENGTH,
          59  +
            content_length,
          60  +
        );
          61  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          62  +
        builder.body(body)?
          63  +
    })
          64  +
}
          65  +
          66  +
#[allow(clippy::unnecessary_wraps)]
          67  +
pub fn ser_malformed_unique_items_http_error(
          68  +
    error: &crate::error::MalformedUniqueItemsError,
          69  +
) -> std::result::Result<
          70  +
    ::aws_smithy_legacy_http_server::response::Response,
          71  +
    ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
          72  +
> {
          73  +
    Ok({
          74  +
        match error {
          75  +
            crate::error::MalformedUniqueItemsError::ValidationException(output) => {
          76  +
                let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
          77  +
                #[allow(unused_mut)]
          78  +
                let mut builder = ::http::Response::builder();
          79  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          80  +
                    builder,
          81  +
                    ::http::header::CONTENT_TYPE,
          82  +
                    "application/json",
          83  +
                );
          84  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          85  +
                    builder,
          86  +
                    ::http::header::HeaderName::from_static("x-amzn-errortype"),
          87  +
                    "ValidationException",
          88  +
                );
          89  +
                let content_length = payload.len();
          90  +
                builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          91  +
                    builder,
          92  +
                    ::http::header::CONTENT_LENGTH,
          93  +
                    content_length,
          94  +
                );
          95  +
                builder
          96  +
                    .status(400)
          97  +
                    .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
          98  +
            }
          99  +
        }
         100  +
    })
         101  +
}
         102  +
         103  +
pub(crate) fn de_malformed_unique_items(
         104  +
    value: &[u8],
         105  +
    mut builder: crate::input::malformed_unique_items_input::Builder,
         106  +
) -> ::std::result::Result<
         107  +
    crate::input::malformed_unique_items_input::Builder,
         108  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
         109  +
> {
         110  +
    let mut tokens_owned =
         111  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
         112  +
            .peekable();
         113  +
    let tokens = &mut tokens_owned;
         114  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
         115  +
    loop {
         116  +
        match tokens.next().transpose()? {
         117  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
         118  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
         119  +
                match key.to_unescaped()?.as_ref() {
         120  +
                    "complexSet" => {
         121  +
                        builder = builder.set_complex_set(
         122  +
                            crate::protocol_serde::shape_complex_set::de_complex_set(tokens)?,
         123  +
                        );
         124  +
                    }
         125  +
                    "set" => {
         126  +
                        builder = builder.set_set(
         127  +
                            crate::protocol_serde::shape_simple_set::de_simple_set(tokens)?,
         128  +
                        );
         129  +
                    }
         130  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         131  +
                }
         132  +
            }
         133  +
            other => {
         134  +
                return Err(
         135  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         136  +
                        "expected object key or end object, found: {other:?}"
         137  +
                    )),
         138  +
                )
         139  +
            }
         140  +
        }
         141  +
    }
         142  +
    if tokens.next().is_some() {
         143  +
        return Err(
         144  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         145  +
                "found more JSON tokens after completing parsing",
         146  +
            ),
         147  +
        );
         148  +
    }
         149  +
    Ok(builder)
         150  +
}

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

@@ -0,1 +0,54 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_simple_set<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained>,
           6  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
           7  +
>
           8  +
where
           9  +
    I: Iterator<
          10  +
        Item = Result<
          11  +
            ::aws_smithy_json::deserialize::Token<'a>,
          12  +
            ::aws_smithy_json::deserialize::error::DeserializeError,
          13  +
        >,
          14  +
    >,
          15  +
{
          16  +
    match tokens.next().transpose()? {
          17  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
          18  +
        Some(::aws_smithy_json::deserialize::Token::StartArray { .. }) => {
          19  +
            let mut items = Vec::new();
          20  +
            loop {
          21  +
                match tokens.peek() {
          22  +
                    Some(Ok(::aws_smithy_json::deserialize::Token::EndArray { .. })) => {
          23  +
                        tokens.next().transpose().unwrap();
          24  +
                        break;
          25  +
                    }
          26  +
                    _ => {
          27  +
                        let value = ::aws_smithy_json::deserialize::token::expect_string_or_null(
          28  +
                            tokens.next(),
          29  +
                        )?
          30  +
                        .map(|s| s.to_unescaped().map(|u| u.into_owned()))
          31  +
                        .transpose()?;
          32  +
                        if let Some(value) = value {
          33  +
                            items.push(value);
          34  +
                        } else {
          35  +
                            return Err(
          36  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          37  +
                                    "dense list cannot contain null values",
          38  +
                                ),
          39  +
                            );
          40  +
                        }
          41  +
                    }
          42  +
                }
          43  +
            }
          44  +
            Ok(Some(
          45  +
                crate::unconstrained::simple_set_unconstrained::SimpleSetUnconstrained(items),
          46  +
            ))
          47  +
        }
          48  +
        _ => Err(
          49  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          50  +
                "expected start array or null",
          51  +
            ),
          52  +
        ),
          53  +
    }
          54  +
}

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

@@ -0,1 +0,35 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_validation_exception_error(
           3  +
    value: &crate::error::ValidationException,
           4  +
) -> ::std::result::Result<String, ::aws_smithy_types::error::operation::SerializationError> {
           5  +
    let mut out = ::std::string::String::new();
           6  +
    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
           7  +
    crate::protocol_serde::shape_validation_exception::ser_validation_exception(
           8  +
        &mut object,
           9  +
        value,
          10  +
    )?;
          11  +
    object.finish();
          12  +
    Ok(out)
          13  +
}
          14  +
          15  +
pub fn ser_validation_exception(
          16  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          17  +
    input: &crate::error::ValidationException,
          18  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          19  +
    if let Some(var_1) = &input.field_list {
          20  +
        let mut array_2 = object.key("fieldList").start_array();
          21  +
        for item_3 in var_1 {
          22  +
            {
          23  +
                #[allow(unused_mut)]
          24  +
                let mut object_4 = array_2.value().start_object();
          25  +
                crate::protocol_serde::shape_validation_exception_field::ser_validation_exception_field(&mut object_4, item_3)?;
          26  +
                object_4.finish();
          27  +
            }
          28  +
        }
          29  +
        array_2.finish();
          30  +
    }
          31  +
    {
          32  +
        object.key("message").string(input.message.as_str());
          33  +
    }
          34  +
    Ok(())
          35  +
}

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

@@ -0,1 +0,13 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_validation_exception_field(
           3  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
           4  +
    input: &crate::model::ValidationExceptionField,
           5  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
           6  +
    {
           7  +
        object.key("path").string(input.path.as_str());
           8  +
    }
           9  +
    {
          10  +
        object.key("message").string(input.message.as_str());
          11  +
    }
          12  +
    Ok(())
          13  +
}

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

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