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_malformed_byte_http_request<B>(
|
4 6 | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 7 | ) -> std::result::Result<
|
6 8 | crate::input::MalformedByteInput,
|
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::malformed_byte_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_malformed_byte::de_malformed_byte(
|
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_malformed_byte_input::de_byte_in_header_header(&headers)?
|
35 47 | {
|
36 48 | input = input.set_byte_in_header(Some(value))
|
37 49 | }
|
50 + | /* ServerHttpBoundProtocolGenerator.kt:986 */
|
38 51 | let input_string = uri.path();
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:998 */
|
39 53 | let (input_string, (_, m1)) =
|
40 54 | ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
|
41 55 | ::nom::sequence::preceded(
|
42 56 | ::nom::bytes::complete::tag("/"),
|
43 57 | ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("MalformedByte"),
|
44 58 | ),
|
45 59 | ::nom::sequence::preceded(
|
46 60 | ::nom::bytes::complete::tag("/"),
|
47 61 | ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
|
48 62 | ::nom::bytes::complete::take_until("/"),
|
49 63 | ::nom::combinator::rest,
|
50 64 | )),
|
51 65 | ),
|
52 66 | ))(input_string)?;
|
53 67 | debug_assert_eq!("", input_string);
|
68 + | /* ServerHttpBoundProtocolGenerator.kt:1009 */
|
54 69 | input = input.set_byte_in_path(
|
55 70 | crate::protocol_serde::shape_malformed_byte_input::de_byte_in_path(m1)?,
|
56 71 | );
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:1073 */
|
57 73 | let query_string = uri.query().unwrap_or("");
|
58 74 | let pairs = ::form_urlencoded::parse(query_string.as_bytes());
|
75 + | /* ServerHttpBoundProtocolGenerator.kt:1099 */
|
59 76 | let mut byte_in_query_seen = false;
|
77 + | /* ServerHttpBoundProtocolGenerator.kt:1105 */
|
60 78 | for (k, v) in pairs {
|
79 + | /* ServerHttpBoundProtocolGenerator.kt:1109 */
|
61 80 | if !byte_in_query_seen && k == "byteInQuery" {
|
62 81 | input = input.set_byte_in_query(
|
63 82 | crate::protocol_serde::shape_malformed_byte_input::de_byte_in_query(&v)?,
|
64 83 | );
|
65 84 | byte_in_query_seen = true;
|
66 85 | }
|
86 + | /* ServerHttpBoundProtocolGenerator.kt:1105 */
|
67 87 | }
|
88 + | /* ServerHttpBoundProtocolGenerator.kt:834 */
|
68 89 | input.build()?
|
90 + | /* ServerHttpBoundProtocolGenerator.kt:399 */
|
69 91 | })
|
92 + | /* ServerHttpBoundProtocolGenerator.kt:383 */
|
70 93 | }
|
71 94 |
|
95 + | /* RustType.kt:516 */
|
72 96 | #[allow(clippy::unnecessary_wraps)]
|
97 + | /* ServerHttpBoundProtocolGenerator.kt:421 */
|
73 98 | pub fn ser_malformed_byte_http_response(
|
74 99 | #[allow(unused_variables)] output: crate::output::MalformedByteOutput,
|
75 100 | ) -> std::result::Result<
|
76 101 | ::aws_smithy_http_server::response::Response,
|
77 102 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
78 103 | > {
|
104 + | /* ServerHttpBoundProtocolGenerator.kt:433 */
|
79 105 | Ok({
|
106 + | /* RustType.kt:516 */
|
80 107 | #[allow(unused_mut)]
|
108 + | /* ServerHttpBoundProtocolGenerator.kt:523 */
|
81 109 | let mut builder = ::http::Response::builder();
|
110 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
82 111 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
83 112 | builder,
|
84 113 | ::http::header::CONTENT_TYPE,
|
85 114 | "application/json",
|
86 115 | );
|
116 + | /* ServerHttpBoundProtocolGenerator.kt:682 */
|
87 117 | let http_status: u16 = 200;
|
88 118 | builder = builder.status(http_status);
|
89 - | let payload = "";
|
119 + | /* ServerHttpBoundProtocolGenerator.kt:561 */
|
120 + | let payload =
|
121 + | /* HttpBoundProtocolPayloadGenerator.kt:235 */""
|
122 + | /* ServerHttpBoundProtocolGenerator.kt:561 */;
|
123 + | /* ServerHttpBoundProtocolGenerator.kt:663 */
|
90 124 | let content_length = payload.len();
|
91 125 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
92 126 | builder,
|
93 127 | ::http::header::CONTENT_LENGTH,
|
94 128 | content_length,
|
95 129 | );
|
130 + | /* ServerHttpBoundProtocolGenerator.kt:567 */
|
96 131 | let body = ::aws_smithy_http_server::body::to_boxed(payload);
|
132 + | /* ServerHttpBoundProtocolGenerator.kt:575 */
|
97 133 | builder.body(body)?
|
134 + | /* ServerHttpBoundProtocolGenerator.kt:433 */
|
98 135 | })
|
136 + | /* ServerHttpBoundProtocolGenerator.kt:421 */
|
99 137 | }
|
100 138 |
|
139 + | /* RustType.kt:516 */
|
101 140 | #[allow(clippy::unnecessary_wraps)]
|
141 + | /* ServerHttpBoundProtocolGenerator.kt:447 */
|
102 142 | pub fn ser_malformed_byte_http_error(
|
103 143 | error: &crate::error::MalformedByteError,
|
104 144 | ) -> std::result::Result<
|
105 145 | ::aws_smithy_http_server::response::Response,
|
106 146 | ::aws_smithy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
107 147 | > {
|
148 + | /* ServerHttpBoundProtocolGenerator.kt:452 */
|
108 149 | Ok({
|
150 + | /* ServerHttpBoundProtocolGenerator.kt:468 */
|
109 151 | match error {
|
152 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
110 153 | crate::error::MalformedByteError::ValidationException(output) => {
|
154 + | /* ServerHttpBoundProtocolGenerator.kt:477 */
|
111 155 | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
156 + | /* RustType.kt:516 */
|
112 157 | #[allow(unused_mut)]
|
158 + | /* ServerHttpBoundProtocolGenerator.kt:487 */
|
113 159 | let mut builder = ::http::Response::builder();
|
160 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
114 161 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
115 162 | builder,
|
116 163 | ::http::header::CONTENT_TYPE,
|
117 164 | "application/json",
|
118 165 | );
|
166 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
119 167 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
120 168 | builder,
|
121 169 | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
122 170 | "ValidationException",
|
123 171 | );
|
172 + | /* ServerHttpBoundProtocolGenerator.kt:663 */
|
124 173 | let content_length = payload.len();
|
125 174 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
126 175 | builder,
|
127 176 | ::http::header::CONTENT_LENGTH,
|
128 177 | content_length,
|
129 178 | );
|
179 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
130 180 | builder
|
131 181 | .status(400)
|
132 182 | .body(::aws_smithy_http_server::body::to_boxed(payload))?
|
183 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
133 184 | }
|
185 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
134 186 | crate::error::MalformedByteError::InternalServerError(output) => {
|
187 + | /* ServerHttpBoundProtocolGenerator.kt:477 */
|
135 188 | let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
|
189 + | /* RustType.kt:516 */
|
136 190 | #[allow(unused_mut)]
|
191 + | /* ServerHttpBoundProtocolGenerator.kt:487 */
|
137 192 | let mut builder = ::http::Response::builder();
|
193 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
138 194 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
139 195 | builder,
|
140 196 | ::http::header::CONTENT_TYPE,
|
141 197 | "application/json",
|
142 198 | );
|
199 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
143 200 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
144 201 | builder,
|
145 202 | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
146 203 | "InternalServerError",
|
147 204 | );
|
205 + | /* ServerHttpBoundProtocolGenerator.kt:663 */
|
148 206 | let content_length = payload.len();
|
149 207 | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
150 208 | builder,
|
151 209 | ::http::header::CONTENT_LENGTH,
|
152 210 | content_length,
|
153 211 | );
|
212 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
154 213 | builder
|
155 214 | .status(500)
|
156 215 | .body(::aws_smithy_http_server::body::to_boxed(payload))?
|
157 - | }
|
216 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
217 + | } /* ServerHttpBoundProtocolGenerator.kt:468 */
|
158 218 | }
|
219 + | /* ServerHttpBoundProtocolGenerator.kt:452 */
|
159 220 | })
|
221 + | /* ServerHttpBoundProtocolGenerator.kt:447 */
|
160 222 | }
|
161 223 |
|
224 + | /* JsonParserGenerator.kt:148 */
|
162 225 | pub(crate) fn de_malformed_byte(
|
163 226 | value: &[u8],
|
164 227 | mut builder: crate::input::malformed_byte_input_internal::Builder,
|
165 228 | ) -> ::std::result::Result<
|
166 229 | crate::input::malformed_byte_input_internal::Builder,
|
167 230 | ::aws_smithy_json::deserialize::error::DeserializeError,
|
168 231 | > {
|
232 + | /* JsonParserGenerator.kt:153 */
|
169 233 | let mut tokens_owned =
|
170 234 | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
171 235 | .peekable();
|
172 236 | let tokens = &mut tokens_owned;
|
173 237 | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
238 + | /* JsonParserGenerator.kt:684 */
|
174 239 | loop {
|
240 + | /* JsonParserGenerator.kt:685 */
|
175 241 | match tokens.next().transpose()? {
|
242 + | /* JsonParserGenerator.kt:686 */
|
176 243 | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
177 244 | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
245 + | /* JsonParserGenerator.kt:260 */
|
178 246 | match key.to_unescaped()?.as_ref() {
|
247 + | /* JsonParserGenerator.kt:262 */
|
179 248 | "byteInBody" => {
|
249 + | /* JsonParserGenerator.kt:272 */
|
180 250 | builder = builder.set_byte_in_body(
|
251 + | /* JsonParserGenerator.kt:365 */
|
181 252 | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
182 253 | tokens.next(),
|
183 254 | )?
|
184 255 | .map(i8::try_from)
|
185 - | .transpose()?,
|
256 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
186 257 | );
|
258 + | /* JsonParserGenerator.kt:262 */
|
187 259 | }
|
188 - | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
260 + | /* JsonParserGenerator.kt:290 */
|
261 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
189 262 | }
|
263 + | /* JsonParserGenerator.kt:686 */
|
190 264 | }
|
265 + | /* JsonParserGenerator.kt:695 */
|
191 266 | other => {
|
192 267 | return Err(
|
193 268 | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
194 269 | "expected object key or end object, found: {:?}",
|
195 270 | other
|
196 271 | )),
|
197 272 | )
|
198 - | }
|
273 + | } /* JsonParserGenerator.kt:685 */
|
199 274 | }
|
275 + | /* JsonParserGenerator.kt:684 */
|
200 276 | }
|
277 + | /* JsonParserGenerator.kt:250 */
|
201 278 | if tokens.next().is_some() {
|
279 + | /* JsonParserGenerator.kt:251 */
|
202 280 | return Err(
|
203 281 | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
204 282 | "found more JSON tokens after completing parsing",
|
205 283 | ),
|
206 284 | );
|
285 + | /* JsonParserGenerator.kt:250 */
|
207 286 | }
|
287 + | /* JsonParserGenerator.kt:163 */
|
208 288 | Ok(builder)
|
289 + | /* JsonParserGenerator.kt:148 */
|
209 290 | }
|