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 + | }
|