1 1 | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /* RustType.kt:516 */
|
2 3 | #[allow(clippy::unnecessary_wraps)]
|
4 + | /* ServerHttpBoundProtocolGenerator.kt:383 */
|
3 5 | pub async fn de_test_body_structure_http_request<B>(
|
4 6 | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 7 | ) -> std::result::Result<
|
6 8 | crate::input::TestBodyStructureInput,
|
7 9 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
8 10 | >
|
9 11 | where
|
10 12 | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
11 13 | B::Data: Send,
|
12 14 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
13 15 | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
14 16 | {
|
17 + | /* ServerHttpBoundProtocolGenerator.kt:399 */
|
15 18 | Ok({
|
19 + | /* RustType.kt:516 */
|
16 20 | #[allow(unused_mut)]
|
21 + | /* ServerHttpBoundProtocolGenerator.kt:723 */
|
17 22 | let mut input = crate::input::test_body_structure_input_internal::Builder::default();
|
23 + | /* RustType.kt:516 */
|
18 24 | #[allow(unused_variables)]
|
25 + | /* ServerHttpBoundProtocolGenerator.kt:728 */
|
19 26 | let ::aws_smithy_runtime_api::http::RequestParts {
|
20 27 | uri, headers, body, ..
|
21 28 | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
29 + | /* ServerHttpBoundProtocolGenerator.kt:745 */
|
22 30 | let bytes = ::hyper::body::to_bytes(body).await?;
|
31 + | /* ServerHttpBoundProtocolGenerator.kt:768 */
|
23 32 | if !bytes.is_empty() {
|
33 + | /* ServerHttpBoundProtocolGenerator.kt:769 */
|
24 34 | ::aws_smithy_http_server::protocol::content_type_header_classifier_smithy(
|
25 35 | &headers,
|
26 36 | Some("application/json"),
|
27 37 | )?;
|
28 38 | input = crate::protocol_serde::shape_test_body_structure::de_test_body_structure(
|
29 39 | bytes.as_ref(),
|
30 40 | input,
|
31 41 | )?;
|
42 + | /* ServerHttpBoundProtocolGenerator.kt:768 */
|
32 43 | }
|
44 + | /* ServerHttpBoundProtocolGenerator.kt:794 */
|
33 45 | if let Some(value) =
|
34 46 | crate::protocol_serde::shape_test_body_structure_input::de_test_id_header(&headers)?
|
35 47 | {
|
36 48 | input = input.set_test_id(Some(value))
|
37 49 | }
|
50 + | /* ServerHttpBoundProtocolGenerator.kt:834 */
|
38 51 | input.build()
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:399 */
|
39 53 | })
|
54 + | /* ServerHttpBoundProtocolGenerator.kt:383 */
|
40 55 | }
|
41 56 |
|
57 + | /* RustType.kt:516 */
|
42 58 | #[allow(clippy::unnecessary_wraps)]
|
59 + | /* ServerHttpBoundProtocolGenerator.kt:421 */
|
43 60 | pub fn ser_test_body_structure_http_response(
|
44 61 | #[allow(unused_variables)] output: crate::output::TestBodyStructureOutput,
|
45 62 | ) -> std::result::Result<
|
46 63 | ::aws_smithy_http_server::response::Response,
|
47 64 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
48 65 | > {
|
66 + | /* ServerHttpBoundProtocolGenerator.kt:433 */
|
49 67 | Ok({
|
68 + | /* RustType.kt:516 */
|
50 69 | #[allow(unused_mut)]
|
70 + | /* ServerHttpBoundProtocolGenerator.kt:523 */
|
51 71 | let mut builder = ::http::Response::builder();
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:629 */
|
52 73 | builder =
|
53 74 | crate::protocol_serde::shape_test_body_structure::ser_test_body_structure_headers(
|
54 75 | &output, builder,
|
55 76 | )?;
|
77 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
56 78 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
57 79 | builder,
|
58 80 | ::http::header::CONTENT_TYPE,
|
59 81 | "application/json",
|
60 82 | );
|
83 + | /* ServerHttpBoundProtocolGenerator.kt:682 */
|
61 84 | let http_status: u16 = 200;
|
62 85 | builder = builder.status(http_status);
|
86 + | /* ServerHttpBoundProtocolGenerator.kt:561 */
|
63 87 | let payload =
|
64 - | crate::protocol_serde::shape_test_body_structure_output::ser_test_body_structure_output_output_output(&output)?
|
65 - | ;
|
88 + | /* HttpBoundProtocolPayloadGenerator.kt:237 */crate::protocol_serde::shape_test_body_structure_output::ser_test_body_structure_output_output_output(&output)?
|
89 + | /* ServerHttpBoundProtocolGenerator.kt:561 */;
|
90 + | /* ServerHttpBoundProtocolGenerator.kt:663 */
|
66 91 | let content_length = payload.len();
|
67 92 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
68 93 | builder,
|
69 94 | ::http::header::CONTENT_LENGTH,
|
70 95 | content_length,
|
71 96 | );
|
97 + | /* ServerHttpBoundProtocolGenerator.kt:567 */
|
72 98 | let body = ::aws_smithy_http_server::body::to_boxed(payload);
|
99 + | /* ServerHttpBoundProtocolGenerator.kt:575 */
|
73 100 | builder.body(body)?
|
101 + | /* ServerHttpBoundProtocolGenerator.kt:433 */
|
74 102 | })
|
103 + | /* ServerHttpBoundProtocolGenerator.kt:421 */
|
75 104 | }
|
76 105 |
|
106 + | /* RustType.kt:516 */
|
77 107 | #[allow(clippy::unnecessary_wraps)]
|
108 + | /* ServerHttpBoundProtocolGenerator.kt:447 */
|
78 109 | pub fn ser_test_body_structure_http_error(
|
79 110 | error: &crate::error::TestBodyStructureError,
|
80 111 | ) -> std::result::Result<
|
81 112 | ::aws_smithy_http_server::response::Response,
|
82 113 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
83 114 | > {
|
115 + | /* ServerHttpBoundProtocolGenerator.kt:452 */
|
84 116 | Ok({
|
117 + | /* ServerHttpBoundProtocolGenerator.kt:468 */
|
85 118 | match error {
|
119 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
86 120 | crate::error::TestBodyStructureError::InternalServerError(output) => {
|
121 + | /* ServerHttpBoundProtocolGenerator.kt:477 */
|
87 122 | let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
|
123 + | /* RustType.kt:516 */
|
88 124 | #[allow(unused_mut)]
|
125 + | /* ServerHttpBoundProtocolGenerator.kt:487 */
|
89 126 | let mut builder = ::http::Response::builder();
|
127 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
90 128 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
91 129 | builder,
|
92 130 | ::http::header::CONTENT_TYPE,
|
93 131 | "application/json",
|
94 132 | );
|
133 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
95 134 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
96 135 | builder,
|
97 136 | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
98 137 | "InternalServerError",
|
99 138 | );
|
139 + | /* ServerHttpBoundProtocolGenerator.kt:663 */
|
100 140 | let content_length = payload.len();
|
101 141 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
102 142 | builder,
|
103 143 | ::http::header::CONTENT_LENGTH,
|
104 144 | content_length,
|
105 145 | );
|
146 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
106 147 | builder
|
107 148 | .status(500)
|
108 149 | .body(::aws_smithy_http_server::body::to_boxed(payload))?
|
150 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
151 + | } /* ServerHttpBoundProtocolGenerator.kt:468 */
|
109 152 | }
|
110 - | }
|
153 + | /* ServerHttpBoundProtocolGenerator.kt:452 */
|
111 154 | })
|
155 + | /* ServerHttpBoundProtocolGenerator.kt:447 */
|
112 156 | }
|
113 157 |
|
158 + | /* JsonParserGenerator.kt:148 */
|
114 159 | pub(crate) fn de_test_body_structure(
|
115 160 | value: &[u8],
|
116 161 | mut builder: crate::input::test_body_structure_input_internal::Builder,
|
117 162 | ) -> ::std::result::Result<
|
118 163 | crate::input::test_body_structure_input_internal::Builder,
|
119 164 | ::aws_smithy_json::deserialize::error::DeserializeError,
|
120 165 | > {
|
166 + | /* JsonParserGenerator.kt:153 */
|
121 167 | let mut tokens_owned =
|
122 168 | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
123 169 | .peekable();
|
124 170 | let tokens = &mut tokens_owned;
|
125 171 | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
172 + | /* JsonParserGenerator.kt:684 */
|
126 173 | loop {
|
174 + | /* JsonParserGenerator.kt:685 */
|
127 175 | match tokens.next().transpose()? {
|
176 + | /* JsonParserGenerator.kt:686 */
|
128 177 | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
129 178 | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
179 + | /* JsonParserGenerator.kt:260 */
|
130 180 | match key.to_unescaped()?.as_ref() {
|
181 + | /* JsonParserGenerator.kt:262 */
|
131 182 | "testConfig" => {
|
183 + | /* JsonParserGenerator.kt:272 */
|
132 184 | builder = builder.set_test_config(
|
133 - | crate::protocol_serde::shape_test_config::de_test_config(tokens)?,
|
134 - | );
|
185 + | /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_test_config::de_test_config(tokens)?
|
186 + | /* JsonParserGenerator.kt:272 */);
|
187 + | /* JsonParserGenerator.kt:262 */
|
135 188 | }
|
136 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
189 + | /* JsonParserGenerator.kt:290 */
|
190 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
137 191 | }
|
192 + | /* JsonParserGenerator.kt:686 */
|
138 193 | }
|
194 + | /* JsonParserGenerator.kt:695 */
|
139 195 | other => {
|
140 196 | return Err(
|
141 197 | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
142 198 | "expected object key or end object, found: {:?}",
|
143 199 | other
|
144 200 | )),
|
145 201 | )
|
202 + | } /* JsonParserGenerator.kt:685 */
|
146 203 | }
|
204 + | /* JsonParserGenerator.kt:684 */
|
147 205 | }
|
148 - | }
|
206 + | /* JsonParserGenerator.kt:250 */
|
149 207 | if tokens.next().is_some() {
|
208 + | /* JsonParserGenerator.kt:251 */
|
150 209 | return Err(
|
151 210 | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
152 211 | "found more JSON tokens after completing parsing",
|
153 212 | ),
|
154 213 | );
|
214 + | /* JsonParserGenerator.kt:250 */
|
155 215 | }
|
216 + | /* JsonParserGenerator.kt:163 */
|
156 217 | Ok(builder)
|
218 + | /* JsonParserGenerator.kt:148 */
|
157 219 | }
|
158 220 |
|
221 + | /* HttpBindingGenerator.kt:542 */
|
159 222 | pub fn ser_test_body_structure_headers(
|
160 223 | input: &crate::output::TestBodyStructureOutput,
|
161 224 | mut builder: ::http::response::Builder,
|
162 225 | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
163 226 | {
|
227 + | /* HttpBindingGenerator.kt:592 */
|
164 228 | if let ::std::option::Option::Some(inner_1) = &input.test_id {
|
229 + | /* HttpBindingGenerator.kt:704 */
|
165 230 | let formatted_2 = inner_1.as_str();
|
231 + | /* HttpBindingGenerator.kt:705 */
|
166 232 | if !formatted_2.is_empty() {
|
233 + | /* HttpBindingGenerator.kt:706 */
|
167 234 | let header_value = formatted_2;
|
168 235 | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
169 236 | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
170 237 | "test_id",
|
171 238 | format!(
|
172 239 | "`{}` cannot be used as a header value: {}",
|
173 240 | &header_value, err
|
174 241 | ),
|
175 242 | )
|
176 243 | })?;
|
177 244 | builder = builder.header("x-amz-test-id", header_value);
|
245 + | /* HttpBindingGenerator.kt:705 */
|
178 246 | }
|
247 + | /* HttpBindingGenerator.kt:592 */
|
179 248 | }
|
249 + | /* HttpBindingGenerator.kt:555 */
|
180 250 | Ok(builder)
|
251 + | /* HttpBindingGenerator.kt:542 */
|
181 252 | }
|