Server Test

Server Test

rev. d06a46cae0f385cdae37a9f8264db3469a090ab5 (ignoring whitespace)

Files changed:

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

@@ -0,1 +0,106 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_some_union<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::SomeUnion>,
           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  +
    let mut variant = None;
          17  +
    match tokens.next().transpose()? {
          18  +
        Some(::aws_smithy_json::deserialize::Token::ValueNull { .. }) => return Ok(None),
          19  +
        Some(::aws_smithy_json::deserialize::Token::StartObject { .. }) => {
          20  +
            loop {
          21  +
                match tokens.next().transpose()? {
          22  +
                    Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          23  +
                    Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          24  +
                        if let ::std::option::Option::Some(::std::result::Result::Ok(
          25  +
                            ::aws_smithy_json::deserialize::Token::ValueNull { .. },
          26  +
                        )) = tokens.peek()
          27  +
                        {
          28  +
                            let _ = tokens.next().expect("peek returned a token")?;
          29  +
                            continue;
          30  +
                        }
          31  +
                        let key = key.to_unescaped()?;
          32  +
                        if key == "__type" {
          33  +
                            ::aws_smithy_json::deserialize::token::skip_value(tokens)?;
          34  +
                            continue;
          35  +
                        }
          36  +
                        if variant.is_some() {
          37  +
                            return Err(
          38  +
                                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          39  +
                                    "encountered mixed variants in union",
          40  +
                                ),
          41  +
                            );
          42  +
                        }
          43  +
                        variant = match key.as_ref() {
          44  +
                            "Result" => {
          45  +
                                Some(crate::model::SomeUnion::Result(
          46  +
                                    crate::protocol_serde::shape_result::de_result(tokens)?
          47  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Result' cannot be null"))?
          48  +
                                ))
          49  +
                            }
          50  +
                            "Option" => {
          51  +
                                Some(crate::model::SomeUnion::Option(
          52  +
                                    crate::protocol_serde::shape_option::de_option(tokens)?
          53  +
                                    .ok_or_else(|| ::aws_smithy_json::deserialize::error::DeserializeError::custom("value for 'Option' cannot be null"))?
          54  +
                                ))
          55  +
                            }
          56  +
                            variant => return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!("unexpected union variant: {variant}")))
          57  +
                        };
          58  +
                    }
          59  +
                    other => {
          60  +
                        return Err(
          61  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          62  +
                                format!("expected object key or end object, found: {other:?}"),
          63  +
                            ),
          64  +
                        )
          65  +
                    }
          66  +
                }
          67  +
            }
          68  +
        }
          69  +
        _ => {
          70  +
            return Err(
          71  +
                ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          72  +
                    "expected start object or null",
          73  +
                ),
          74  +
            )
          75  +
        }
          76  +
    }
          77  +
    if variant.is_none() {
          78  +
        return Err(
          79  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          80  +
                "Union did not contain a valid variant.",
          81  +
            ),
          82  +
        );
          83  +
    }
          84  +
    Ok(variant)
          85  +
}
          86  +
          87  +
pub fn ser_some_union(
          88  +
    object_14: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          89  +
    input: &crate::model::SomeUnion,
          90  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          91  +
    match input {
          92  +
        crate::model::SomeUnion::Result(inner) => {
          93  +
            #[allow(unused_mut)]
          94  +
            let mut object_1 = object_14.key("Result").start_object();
          95  +
            crate::protocol_serde::shape_result::ser_result(&mut object_1, inner)?;
          96  +
            object_1.finish();
          97  +
        }
          98  +
        crate::model::SomeUnion::Option(inner) => {
          99  +
            #[allow(unused_mut)]
         100  +
            let mut object_2 = object_14.key("Option").start_object();
         101  +
            crate::protocol_serde::shape_option::ser_option(&mut object_2, inner)?;
         102  +
            object_2.finish();
         103  +
        }
         104  +
    }
         105  +
    Ok(())
         106  +
}

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

@@ -0,1 +0,121 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub(crate) fn de_something_else<'a, I>(
           3  +
    tokens: &mut ::std::iter::Peekable<I>,
           4  +
) -> ::std::result::Result<
           5  +
    Option<crate::model::SomethingElse>,
           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::something_else::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, .. }) => match key
          25  +
                        .to_unescaped()?
          26  +
                        .as_ref()
          27  +
                    {
          28  +
                        "result" => {
          29  +
                            builder = builder.set_result(
          30  +
                                crate::protocol_serde::shape_result::de_result(tokens)?,
          31  +
                            );
          32  +
                        }
          33  +
                        "resultList" => {
          34  +
                            builder = builder.set_result_list(
          35  +
                                crate::protocol_serde::shape_result_list::de_result_list(tokens)?,
          36  +
                            );
          37  +
                        }
          38  +
                        "option" => {
          39  +
                            builder = builder.set_option(
          40  +
                                crate::protocol_serde::shape_option::de_option(tokens)?,
          41  +
                            );
          42  +
                        }
          43  +
                        "optionList" => {
          44  +
                            builder = builder.set_option_list(
          45  +
                                crate::protocol_serde::shape_option_list::de_option_list(tokens)?,
          46  +
                            );
          47  +
                        }
          48  +
                        "someUnion" => {
          49  +
                            builder = builder.set_some_union(
          50  +
                                crate::protocol_serde::shape_some_union::de_some_union(tokens)?,
          51  +
                            );
          52  +
                        }
          53  +
                        _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
          54  +
                    },
          55  +
                    other => {
          56  +
                        return Err(
          57  +
                            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          58  +
                                format!("expected object key or end object, found: {other:?}"),
          59  +
                            ),
          60  +
                        )
          61  +
                    }
          62  +
                }
          63  +
            }
          64  +
            Ok(Some(builder.build()))
          65  +
        }
          66  +
        _ => Err(
          67  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
          68  +
                "expected start object or null",
          69  +
            ),
          70  +
        ),
          71  +
    }
          72  +
}
          73  +
          74  +
pub fn ser_something_else(
          75  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          76  +
    input: &crate::model::SomethingElse,
          77  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          78  +
    if let Some(var_1) = &input.result {
          79  +
        #[allow(unused_mut)]
          80  +
        let mut object_2 = object.key("result").start_object();
          81  +
        crate::protocol_serde::shape_result::ser_result(&mut object_2, var_1)?;
          82  +
        object_2.finish();
          83  +
    }
          84  +
    if let Some(var_3) = &input.result_list {
          85  +
        let mut array_4 = object.key("resultList").start_array();
          86  +
        for item_5 in var_3 {
          87  +
            {
          88  +
                #[allow(unused_mut)]
          89  +
                let mut object_6 = array_4.value().start_object();
          90  +
                crate::protocol_serde::shape_result::ser_result(&mut object_6, item_5)?;
          91  +
                object_6.finish();
          92  +
            }
          93  +
        }
          94  +
        array_4.finish();
          95  +
    }
          96  +
    if let Some(var_7) = &input.option {
          97  +
        #[allow(unused_mut)]
          98  +
        let mut object_8 = object.key("option").start_object();
          99  +
        crate::protocol_serde::shape_option::ser_option(&mut object_8, var_7)?;
         100  +
        object_8.finish();
         101  +
    }
         102  +
    if let Some(var_9) = &input.option_list {
         103  +
        let mut array_10 = object.key("optionList").start_array();
         104  +
        for item_11 in var_9 {
         105  +
            {
         106  +
                #[allow(unused_mut)]
         107  +
                let mut object_12 = array_10.value().start_object();
         108  +
                crate::protocol_serde::shape_result::ser_result(&mut object_12, item_11)?;
         109  +
                object_12.finish();
         110  +
            }
         111  +
        }
         112  +
        array_10.finish();
         113  +
    }
         114  +
    if let Some(var_13) = &input.some_union {
         115  +
        #[allow(unused_mut)]
         116  +
        let mut object_14 = object.key("someUnion").start_object();
         117  +
        crate::protocol_serde::shape_some_union::ser_some_union(&mut object_14, var_13)?;
         118  +
        object_14.finish();
         119  +
    }
         120  +
    Ok(())
         121  +
}

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

@@ -0,1 +0,124 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
#[allow(clippy::unnecessary_wraps)]
           3  +
pub async fn de_structs_http_request<B>(
           4  +
    #[allow(unused_variables)] request: ::http::Request<B>,
           5  +
) -> std::result::Result<
           6  +
    crate::input::StructsInput,
           7  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::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::aws_json::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::structs_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/x-amz-json-1.1"),
          27  +
            )?;
          28  +
            input = crate::protocol_serde::shape_structs::de_structs(bytes.as_ref(), input)?;
          29  +
        }
          30  +
        input.build()
          31  +
    })
          32  +
}
          33  +
          34  +
#[allow(clippy::unnecessary_wraps)]
          35  +
pub fn ser_structs_http_response(
          36  +
    #[allow(unused_variables)] output: crate::output::StructsOutput,
          37  +
) -> std::result::Result<
          38  +
    ::aws_smithy_legacy_http_server::response::Response,
          39  +
    ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
          40  +
> {
          41  +
    Ok({
          42  +
        #[allow(unused_mut)]
          43  +
        let mut builder = ::http::Response::builder();
          44  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          45  +
            builder,
          46  +
            ::http::header::CONTENT_TYPE,
          47  +
            "application/x-amz-json-1.1",
          48  +
        );
          49  +
        let http_status: u16 = 200;
          50  +
        builder = builder.status(http_status);
          51  +
        let payload =
          52  +
            crate::protocol_serde::shape_structs_output::ser_structs_output_output_output(&output)?;
          53  +
        let content_length = payload.len();
          54  +
        builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
          55  +
            builder,
          56  +
            ::http::header::CONTENT_LENGTH,
          57  +
            content_length,
          58  +
        );
          59  +
        let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
          60  +
        builder.body(body)?
          61  +
    })
          62  +
}
          63  +
          64  +
pub(crate) fn de_structs(
          65  +
    value: &[u8],
          66  +
    mut builder: crate::input::structs_input::Builder,
          67  +
) -> ::std::result::Result<
          68  +
    crate::input::structs_input::Builder,
          69  +
    ::aws_smithy_json::deserialize::error::DeserializeError,
          70  +
> {
          71  +
    let mut tokens_owned =
          72  +
        ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
          73  +
            .peekable();
          74  +
    let tokens = &mut tokens_owned;
          75  +
    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
          76  +
    loop {
          77  +
        match tokens.next().transpose()? {
          78  +
            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
          79  +
            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
          80  +
                match key.to_unescaped()?.as_ref() {
          81  +
                    "result" => {
          82  +
                        builder = builder
          83  +
                            .set_result(crate::protocol_serde::shape_result::de_result(tokens)?);
          84  +
                    }
          85  +
                    "resultList" => {
          86  +
                        builder = builder.set_result_list(
          87  +
                            crate::protocol_serde::shape_result_list::de_result_list(tokens)?,
          88  +
                        );
          89  +
                    }
          90  +
                    "option" => {
          91  +
                        builder = builder
          92  +
                            .set_option(crate::protocol_serde::shape_option::de_option(tokens)?);
          93  +
                    }
          94  +
                    "optionList" => {
          95  +
                        builder = builder.set_option_list(
          96  +
                            crate::protocol_serde::shape_option_list::de_option_list(tokens)?,
          97  +
                        );
          98  +
                    }
          99  +
                    "somethingElse" => {
         100  +
                        builder = builder.set_something_else(
         101  +
                            crate::protocol_serde::shape_something_else::de_something_else(tokens)?,
         102  +
                        );
         103  +
                    }
         104  +
                    _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
         105  +
                }
         106  +
            }
         107  +
            other => {
         108  +
                return Err(
         109  +
                    ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
         110  +
                        "expected object key or end object, found: {other:?}"
         111  +
                    )),
         112  +
                )
         113  +
            }
         114  +
        }
         115  +
    }
         116  +
    if tokens.next().is_some() {
         117  +
        return Err(
         118  +
            ::aws_smithy_json::deserialize::error::DeserializeError::custom(
         119  +
                "found more JSON tokens after completing parsing",
         120  +
            ),
         121  +
        );
         122  +
    }
         123  +
    Ok(builder)
         124  +
}

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

@@ -0,1 +0,59 @@
           1  +
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
           2  +
pub fn ser_structs_output_output_output(
           3  +
    value: &crate::output::StructsOutput,
           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_structs_output::ser_structs_output_output(&mut object, value)?;
           8  +
    object.finish();
           9  +
    Ok(out)
          10  +
}
          11  +
          12  +
pub fn ser_structs_output_output(
          13  +
    object: &mut ::aws_smithy_json::serialize::JsonObjectWriter,
          14  +
    input: &crate::output::StructsOutput,
          15  +
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
          16  +
    if let Some(var_1) = &input.result {
          17  +
        #[allow(unused_mut)]
          18  +
        let mut object_2 = object.key("result").start_object();
          19  +
        crate::protocol_serde::shape_result::ser_result(&mut object_2, var_1)?;
          20  +
        object_2.finish();
          21  +
    }
          22  +
    if let Some(var_3) = &input.result_list {
          23  +
        let mut array_4 = object.key("resultList").start_array();
          24  +
        for item_5 in var_3 {
          25  +
            {
          26  +
                #[allow(unused_mut)]
          27  +
                let mut object_6 = array_4.value().start_object();
          28  +
                crate::protocol_serde::shape_result::ser_result(&mut object_6, item_5)?;
          29  +
                object_6.finish();
          30  +
            }
          31  +
        }
          32  +
        array_4.finish();
          33  +
    }
          34  +
    if let Some(var_7) = &input.option {
          35  +
        #[allow(unused_mut)]
          36  +
        let mut object_8 = object.key("option").start_object();
          37  +
        crate::protocol_serde::shape_option::ser_option(&mut object_8, var_7)?;
          38  +
        object_8.finish();
          39  +
    }
          40  +
    if let Some(var_9) = &input.option_list {
          41  +
        let mut array_10 = object.key("optionList").start_array();
          42  +
        for item_11 in var_9 {
          43  +
            {
          44  +
                #[allow(unused_mut)]
          45  +
                let mut object_12 = array_10.value().start_object();
          46  +
                crate::protocol_serde::shape_result::ser_result(&mut object_12, item_11)?;
          47  +
                object_12.finish();
          48  +
            }
          49  +
        }
          50  +
        array_10.finish();
          51  +
    }
          52  +
    if let Some(var_13) = &input.something_else {
          53  +
        #[allow(unused_mut)]
          54  +
        let mut object_14 = object.key("somethingElse").start_object();
          55  +
        crate::protocol_serde::shape_something_else::ser_something_else(&mut object_14, var_13)?;
          56  +
        object_14.finish();
          57  +
    }
          58  +
    Ok(())
          59  +
}

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

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