1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 2 | /// The service builder for [`JsonRpc10`].
|
3 3 | ///
|
4 4 | /// Constructed via [`JsonRpc10::builder`].
|
5 5 | pub struct JsonRpc10Builder<Body, L, HttpPl, ModelPl> {
|
6 + | content_type_parameters: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
6 7 | empty_input_and_empty_output: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
7 8 | endpoint_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
8 9 | endpoint_with_host_label_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
9 10 | greeting_with_errors: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
10 11 | host_with_path_operation: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
11 12 | json_unions: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
12 13 | no_input_and_no_output: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
13 14 | no_input_and_output: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
14 15 | operation_with_defaults: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
15 16 | operation_with_nested_structure: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
16 17 | operation_with_required_members: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
17 18 | put_with_content_encoding: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
18 19 | simple_scalar_properties: Option<::aws_smithy_http_server::routing::Route<Body>>,
|
19 20 | layer: L,
|
20 21 | http_plugin: HttpPl,
|
21 22 | model_plugin: ModelPl,
|
22 23 | }
|
23 24 |
|
24 25 | impl<Body, L, HttpPl, ModelPl> JsonRpc10Builder<Body, L, HttpPl, ModelPl> {
|
26 + | /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) operation.
|
27 + | ///
|
28 + | /// This should be an async function satisfying the [`Handler`](::aws_smithy_http_server::operation::Handler) trait.
|
29 + | /// See the [operation module documentation](::aws_smithy_http_server::operation) for more information.
|
30 + | ///
|
31 + | /// # Example
|
32 + | ///
|
33 + | /// ```no_run
|
34 + | /// use json_rpc10::{JsonRpc10, JsonRpc10Config};
|
35 + | ///
|
36 + | /// use json_rpc10::{input, output, error};
|
37 + | ///
|
38 + | /// async fn handler(input: input::ContentTypeParametersInput) -> Result<output::ContentTypeParametersOutput, error::ContentTypeParametersError> {
|
39 + | /// todo!()
|
40 + | /// }
|
41 + | ///
|
42 + | /// let config = JsonRpc10Config::builder().build();
|
43 + | /// let app = JsonRpc10::builder(config)
|
44 + | /// .content_type_parameters(handler)
|
45 + | /// /* Set other handlers */
|
46 + | /// .build()
|
47 + | /// .unwrap();
|
48 + | /// # let app: JsonRpc10<::aws_smithy_http_server::routing::RoutingService<::aws_smithy_http_server::protocol::aws_json::router::AwsJsonRouter<::aws_smithy_http_server::routing::Route>, ::aws_smithy_http_server::protocol::aws_json_10::AwsJson1_0>> = app;
|
49 + | /// ```
|
50 + | ///
|
51 + | pub fn content_type_parameters<HandlerType, HandlerExtractors, UpgradeExtractors>(self, handler: HandlerType) -> Self
|
52 + | where
|
53 + | HandlerType: ::aws_smithy_http_server::operation::Handler<crate::operation_shape::ContentTypeParameters, HandlerExtractors>,
|
54 + |
|
55 + | ModelPl: ::aws_smithy_http_server::plugin::Plugin<
|
56 + | JsonRpc10<L>,
|
57 + | crate::operation_shape::ContentTypeParameters,
|
58 + | ::aws_smithy_http_server::operation::IntoService<crate::operation_shape::ContentTypeParameters, HandlerType>
|
59 + | >,
|
60 + | ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_http_server::plugin::Plugin<
|
61 + | JsonRpc10<L>,
|
62 + | crate::operation_shape::ContentTypeParameters,
|
63 + | ModelPl::Output
|
64 + | >,
|
65 + | HttpPl: ::aws_smithy_http_server::plugin::Plugin<
|
66 + | JsonRpc10<L>,
|
67 + | crate::operation_shape::ContentTypeParameters,
|
68 + | <
|
69 + | ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
|
70 + | as ::aws_smithy_http_server::plugin::Plugin<
|
71 + | JsonRpc10<L>,
|
72 + | crate::operation_shape::ContentTypeParameters,
|
73 + | ModelPl::Output
|
74 + | >
|
75 + | >::Output
|
76 + | >,
|
77 + |
|
78 + | HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
|
79 + | <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
|
80 + |
|
81 + | {
|
82 + | use ::aws_smithy_http_server::operation::OperationShapeExt;
|
83 + | use ::aws_smithy_http_server::plugin::Plugin;
|
84 + | let svc = crate::operation_shape::ContentTypeParameters::from_handler(handler);
|
85 + | let svc = self.model_plugin.apply(svc);
|
86 + | let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
|
87 + | .apply(svc);
|
88 + | let svc = self.http_plugin.apply(svc);
|
89 + | self.content_type_parameters_custom(svc)
|
90 + | }
|
91 + |
|
92 + | /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) operation.
|
93 + | ///
|
94 + | /// This should be an async function satisfying the [`Handler`](::aws_smithy_http_server::operation::Handler) trait.
|
95 + | /// See the [operation module documentation](::aws_smithy_http_server::operation) for more information.
|
96 + | ///
|
97 + | /// # Example
|
98 + | ///
|
99 + | /// ```no_run
|
100 + | /// use json_rpc10::{JsonRpc10, JsonRpc10Config};
|
101 + | ///
|
102 + | /// use json_rpc10::{input, output, error};
|
103 + | ///
|
104 + | /// async fn handler(input: input::ContentTypeParametersInput) -> Result<output::ContentTypeParametersOutput, error::ContentTypeParametersError> {
|
105 + | /// todo!()
|
106 + | /// }
|
107 + | ///
|
108 + | /// let config = JsonRpc10Config::builder().build();
|
109 + | /// let svc = ::tower::util::service_fn(handler);
|
110 + | /// let app = JsonRpc10::builder(config)
|
111 + | /// .content_type_parameters_service(svc)
|
112 + | /// /* Set other handlers */
|
113 + | /// .build()
|
114 + | /// .unwrap();
|
115 + | /// # let app: JsonRpc10<::aws_smithy_http_server::routing::RoutingService<::aws_smithy_http_server::protocol::aws_json::router::AwsJsonRouter<::aws_smithy_http_server::routing::Route>, ::aws_smithy_http_server::protocol::aws_json_10::AwsJson1_0>> = app;
|
116 + | /// ```
|
117 + | ///
|
118 + | pub fn content_type_parameters_service<S, ServiceExtractors, UpgradeExtractors>(self, service: S) -> Self
|
119 + | where
|
120 + | S: ::aws_smithy_http_server::operation::OperationService<crate::operation_shape::ContentTypeParameters, ServiceExtractors>,
|
121 + |
|
122 + | ModelPl: ::aws_smithy_http_server::plugin::Plugin<
|
123 + | JsonRpc10<L>,
|
124 + | crate::operation_shape::ContentTypeParameters,
|
125 + | ::aws_smithy_http_server::operation::Normalize<crate::operation_shape::ContentTypeParameters, S>
|
126 + | >,
|
127 + | ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>: ::aws_smithy_http_server::plugin::Plugin<
|
128 + | JsonRpc10<L>,
|
129 + | crate::operation_shape::ContentTypeParameters,
|
130 + | ModelPl::Output
|
131 + | >,
|
132 + | HttpPl: ::aws_smithy_http_server::plugin::Plugin<
|
133 + | JsonRpc10<L>,
|
134 + | crate::operation_shape::ContentTypeParameters,
|
135 + | <
|
136 + | ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>
|
137 + | as ::aws_smithy_http_server::plugin::Plugin<
|
138 + | JsonRpc10<L>,
|
139 + | crate::operation_shape::ContentTypeParameters,
|
140 + | ModelPl::Output
|
141 + | >
|
142 + | >::Output
|
143 + | >,
|
144 + |
|
145 + | HttpPl::Output: ::tower::Service<::http::Request<Body>, Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>, Error = ::std::convert::Infallible> + Clone + Send + 'static,
|
146 + | <HttpPl::Output as ::tower::Service<::http::Request<Body>>>::Future: Send + 'static,
|
147 + |
|
148 + | {
|
149 + | use ::aws_smithy_http_server::operation::OperationShapeExt;
|
150 + | use ::aws_smithy_http_server::plugin::Plugin;
|
151 + | let svc = crate::operation_shape::ContentTypeParameters::from_service(service);
|
152 + | let svc = self.model_plugin.apply(svc);
|
153 + | let svc = ::aws_smithy_http_server::operation::UpgradePlugin::<UpgradeExtractors>::new()
|
154 + | .apply(svc);
|
155 + | let svc = self.http_plugin.apply(svc);
|
156 + | self.content_type_parameters_custom(svc)
|
157 + | }
|
158 + |
|
159 + | /// Sets the [`ContentTypeParameters`](crate::operation_shape::ContentTypeParameters) to a custom [`Service`](tower::Service).
|
160 + | /// not constrained by the Smithy contract.
|
161 + | fn content_type_parameters_custom<S>(mut self, svc: S) -> Self
|
162 + | where
|
163 + | S: ::tower::Service<
|
164 + | ::http::Request<Body>,
|
165 + | Response = ::http::Response<::aws_smithy_http_server::body::BoxBody>,
|
166 + | Error = ::std::convert::Infallible,
|
167 + | > + Clone
|
168 + | + Send
|
169 + | + 'static,
|
170 + | S::Future: Send + 'static,
|
171 + | {
|
172 + | self.content_type_parameters = Some(::aws_smithy_http_server::routing::Route::new(svc));
|
173 + | self
|
174 + | }
|
175 + |
|
25 176 | /// Sets the [`EmptyInputAndEmptyOutput`](crate::operation_shape::EmptyInputAndEmptyOutput) operation.
|
26 177 | ///
|
27 178 | /// This should be an async function satisfying the [`Handler`](::aws_smithy_http_server::operation::Handler) trait.
|
28 179 | /// See the [operation module documentation](::aws_smithy_http_server::operation) for more information.
|
29 180 | ///
|
30 181 | /// # Example
|
31 182 | ///
|
32 183 | /// ```no_run
|
33 184 | /// use json_rpc10::{JsonRpc10, JsonRpc10Config};
|
34 185 | ///
|
2390 2563 | /// to the operations in this service.
|
2391 2564 | pub fn builder<
|
2392 2565 | Body,
|
2393 2566 | L,
|
2394 2567 | HttpPl: ::aws_smithy_http_server::plugin::HttpMarker,
|
2395 2568 | ModelPl: ::aws_smithy_http_server::plugin::ModelMarker,
|
2396 2569 | >(
|
2397 2570 | config: JsonRpc10Config<L, HttpPl, ModelPl>,
|
2398 2571 | ) -> JsonRpc10Builder<Body, L, HttpPl, ModelPl> {
|
2399 2572 | JsonRpc10Builder {
|
2573 + | content_type_parameters: None,
|
2400 2574 | empty_input_and_empty_output: None,
|
2401 2575 | endpoint_operation: None,
|
2402 2576 | endpoint_with_host_label_operation: None,
|
2403 2577 | greeting_with_errors: None,
|
2404 2578 | host_with_path_operation: None,
|
2405 2579 | json_unions: None,
|
2406 2580 | no_input_and_no_output: None,
|
2407 2581 | no_input_and_output: None,
|
2408 2582 | operation_with_defaults: None,
|
2409 2583 | operation_with_nested_structure: None,
|
2410 2584 | operation_with_required_members: None,
|
2411 2585 | put_with_content_encoding: None,
|
2412 2586 | simple_scalar_properties: None,
|
2413 2587 | layer: config.layers,
|
2414 2588 | http_plugin: config.http_plugins,
|
2415 2589 | model_plugin: config.model_plugins,
|
2416 2590 | }
|
2417 2591 | }
|
2418 2592 |
|
2419 2593 | /// Constructs a builder for [`JsonRpc10`].
|
2420 2594 | /// You must specify what plugins should be applied to the operations in this service.
|
2421 2595 | ///
|
2422 2596 | /// Use [`JsonRpc10::builder_without_plugins`] if you don't need to apply plugins.
|
2423 2597 | ///
|
2424 2598 | /// Check out [`HttpPlugins`](::aws_smithy_http_server::plugin::HttpPlugins) and
|
2425 2599 | /// [`ModelPlugins`](::aws_smithy_http_server::plugin::ModelPlugins) if you need to apply
|
2426 2600 | /// multiple plugins.
|
2427 2601 | #[deprecated(
|
2428 2602 | since = "0.57.0",
|
2429 2603 | note = "please use the `builder` constructor and register plugins on the `JsonRpc10Config` object instead; see https://github.com/smithy-lang/smithy-rs/discussions/3096"
|
2430 2604 | )]
|
2431 2605 | pub fn builder_with_plugins<
|
2432 2606 | Body,
|
2433 2607 | HttpPl: ::aws_smithy_http_server::plugin::HttpMarker,
|
2434 2608 | ModelPl: ::aws_smithy_http_server::plugin::ModelMarker,
|
2435 2609 | >(
|
2436 2610 | http_plugin: HttpPl,
|
2437 2611 | model_plugin: ModelPl,
|
2438 2612 | ) -> JsonRpc10Builder<Body, ::tower::layer::util::Identity, HttpPl, ModelPl> {
|
2439 2613 | JsonRpc10Builder {
|
2614 + | content_type_parameters: None,
|
2440 2615 | empty_input_and_empty_output: None,
|
2441 2616 | endpoint_operation: None,
|
2442 2617 | endpoint_with_host_label_operation: None,
|
2443 2618 | greeting_with_errors: None,
|
2444 2619 | host_with_path_operation: None,
|
2445 2620 | json_unions: None,
|
2446 2621 | no_input_and_no_output: None,
|
2447 2622 | no_input_and_output: None,
|
2448 2623 | operation_with_defaults: None,
|
2449 2624 | operation_with_nested_structure: None,
|
2565 2740 |
|
2566 2741 | fn call(&mut self, request: R) -> Self::Future {
|
2567 2742 | self.svc.call(request)
|
2568 2743 | }
|
2569 2744 | }
|
2570 2745 |
|
2571 2746 | /// An enumeration of all [operations](https://smithy.io/2.0/spec/service-types.html#operation) in JsonRpc10.
|
2572 2747 | #[allow(clippy::enum_variant_names)]
|
2573 2748 | #[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
2574 2749 | pub enum Operation {
|
2750 + | ContentTypeParameters,
|
2575 2751 | EmptyInputAndEmptyOutput,
|
2576 2752 | EndpointOperation,
|
2577 2753 | EndpointWithHostLabelOperation,
|
2578 2754 | GreetingWithErrors,
|
2579 2755 | HostWithPathOperation,
|
2580 2756 | JsonUnions,
|
2581 2757 | NoInputAndNoOutput,
|
2582 2758 | NoInputAndOutput,
|
2583 2759 | OperationWithDefaults,
|
2584 2760 | OperationWithNestedStructure,
|
2585 2761 | OperationWithRequiredMembers,
|
2586 2762 | PutWithContentEncoding,
|
2587 2763 | SimpleScalarProperties,
|
2588 2764 | }
|
2589 2765 |
|
2590 2766 | impl Operation {
|
2591 2767 | /// Returns the [operations](https://smithy.io/2.0/spec/service-types.html#operation) [`ShapeId`](::aws_smithy_http_server::shape_id::ShapeId).
|
2592 2768 | pub fn shape_id(&self) -> ::aws_smithy_http_server::shape_id::ShapeId {
|
2593 2769 | match self {
|
2770 + | Operation::ContentTypeParameters => ::aws_smithy_http_server::shape_id::ShapeId::new(
|
2771 + | "aws.protocoltests.json10#ContentTypeParameters",
|
2772 + | "aws.protocoltests.json10",
|
2773 + | "ContentTypeParameters",
|
2774 + | ),
|
2594 2775 | Operation::EmptyInputAndEmptyOutput => {
|
2595 2776 | ::aws_smithy_http_server::shape_id::ShapeId::new(
|
2596 2777 | "aws.protocoltests.json10#EmptyInputAndEmptyOutput",
|
2597 2778 | "aws.protocoltests.json10",
|
2598 2779 | "EmptyInputAndEmptyOutput",
|
2599 2780 | )
|
2600 2781 | }
|
2601 2782 | Operation::EndpointOperation => ::aws_smithy_http_server::shape_id::ShapeId::new(
|
2602 2783 | "aws.protocoltests.json10#EndpointOperation",
|
2603 2784 | "aws.protocoltests.json10",
|
2884 3072 | }
|
2885 3073 | /// A macro to help with scoping [plugins](::aws_smithy_http_server::plugin) to a subset of all operations.
|
2886 3074 | ///
|
2887 3075 | /// In contrast to [`aws_smithy_http_server::scope`](::aws_smithy_http_server::scope), this macro has knowledge
|
2888 3076 | /// of the service and any operations _not_ specified will be placed in the opposing group.
|
2889 3077 | ///
|
2890 3078 | /// # Example
|
2891 3079 | ///
|
2892 3080 | /// ```rust
|
2893 3081 | /// scope! {
|
2894 - | /// /// Includes [`EmptyInputAndEmptyOutput`], excluding all other operations.
|
3082 + | /// /// Includes [`ContentTypeParameters`], excluding all other operations.
|
2895 3083 | /// struct ScopeA {
|
2896 - | /// includes: [EmptyInputAndEmptyOutput]
|
3084 + | /// includes: [ContentTypeParameters]
|
2897 3085 | /// }
|
2898 3086 | /// }
|
2899 3087 | ///
|
2900 3088 | /// scope! {
|
2901 - | /// /// Excludes [`EmptyInputAndEmptyOutput`], excluding all other operations.
|
3089 + | /// /// Excludes [`ContentTypeParameters`], excluding all other operations.
|
2902 3090 | /// struct ScopeB {
|
2903 - | /// excludes: [EmptyInputAndEmptyOutput]
|
3091 + | /// excludes: [ContentTypeParameters]
|
2904 3092 | /// }
|
2905 3093 | /// }
|
2906 3094 | ///
|
2907 3095 | /// # use ::aws_smithy_http_server::plugin::{Plugin, Scoped};
|
2908 3096 | /// # use json_rpc10::scope;
|
2909 3097 | /// # struct MockPlugin;
|
2910 3098 | /// # impl<S, Op, T> Plugin<S, Op, T> for MockPlugin { type Output = u32; fn apply(&self, input: T) -> u32 { 3 } }
|
2911 3099 | /// # let scoped_a = Scoped::new::<ScopeA>(MockPlugin);
|
2912 3100 | /// # let scoped_b = Scoped::new::<ScopeB>(MockPlugin);
|
2913 - | /// # let a = Plugin::<(), json_rpc10::operation_shape::EmptyInputAndEmptyOutput, u64>::apply(&scoped_a, 6);
|
2914 - | /// # let b = Plugin::<(), json_rpc10::operation_shape::EmptyInputAndEmptyOutput, u64>::apply(&scoped_b, 6);
|
3101 + | /// # let a = Plugin::<(), json_rpc10::operation_shape::ContentTypeParameters, u64>::apply(&scoped_a, 6);
|
3102 + | /// # let b = Plugin::<(), json_rpc10::operation_shape::ContentTypeParameters, u64>::apply(&scoped_b, 6);
|
2915 3103 | /// # assert_eq!(a, 3_u32);
|
2916 3104 | /// # assert_eq!(b, 6_u64);
|
2917 3105 | /// ```
|
2918 3106 | #[macro_export]
|
2919 3107 | macro_rules! scope {
|
2920 3108 | // Completed, render impls
|
2921 3109 | (@ $ name: ident, $ contains: ident () ($($ temp: ident)*) ($($ not_member: ident)*)) => {
|
2922 3110 | $(
|
2923 3111 | impl ::aws_smithy_http_server::plugin::scoped::Membership<$ temp> for $ name {
|
2924 3112 | type Contains = ::aws_smithy_http_server::plugin::scoped::$ contains;
|
2925 3113 | }
|
2926 3114 | )*
|
2927 3115 | $(
|
2928 3116 | impl ::aws_smithy_http_server::plugin::scoped::Membership<$ not_member> for $ name {
|
2929 3117 | type Contains = ::aws_smithy_http_server::plugin::scoped::$ contains;
|
2930 3118 | }
|
2931 3119 | )*
|
2932 3120 | };
|
2933 3121 | // All `not_member`s exhausted, move `temp` into `not_member`
|
2934 3122 | (@ $ name: ident, $ contains: ident ($($ member: ident)*) ($($ temp: ident)*) ()) => {
|
2935 3123 | scope! { @ $ name, $ contains ($($ member)*) () ($($ temp)*) }
|
2936 3124 | };
|
2937 3125 |
|
3126 + | // ContentTypeParameters match found, pop from both `member` and `not_member`
|
3127 + | (@ $ name: ident, $ contains: ident (ContentTypeParameters $($ member: ident)*) ($($ temp: ident)*) (ContentTypeParameters $($ not_member: ident)*)) => {
|
3128 + | scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
|
3129 + | };
|
3130 + | // ContentTypeParameters match not found, pop from `not_member` into `temp` stack
|
3131 + | (@ $ name: ident, $ contains: ident (ContentTypeParameters $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
|
3132 + | scope! { @ $ name, $ contains (ContentTypeParameters $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
|
3133 + | };
|
3134 + |
|
2938 3135 | // EmptyInputAndEmptyOutput match found, pop from both `member` and `not_member`
|
2939 3136 | (@ $ name: ident, $ contains: ident (EmptyInputAndEmptyOutput $($ member: ident)*) ($($ temp: ident)*) (EmptyInputAndEmptyOutput $($ not_member: ident)*)) => {
|
2940 3137 | scope! { @ $ name, $ contains ($($ member)*) ($($ temp)*) ($($ not_member)*) }
|
2941 3138 | };
|
2942 3139 | // EmptyInputAndEmptyOutput match not found, pop from `not_member` into `temp` stack
|
2943 3140 | (@ $ name: ident, $ contains: ident (EmptyInputAndEmptyOutput $($ member: ident)*) ($($ temp: ident)*) ($ other: ident $($ not_member: ident)*)) => {
|
2944 3141 | scope! { @ $ name, $ contains (EmptyInputAndEmptyOutput $($ member)*) ($ other $($ temp)*) ($($ not_member)*) }
|
2945 3142 | };
|
2946 3143 |
|
2947 3144 | // EndpointOperation match found, pop from both `member` and `not_member`
|