1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | /* RustType.kt:534 */
|
3 + | #[allow(clippy::unnecessary_wraps)]
|
4 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
5 + | pub async fn de_malformed_integer_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::MalformedIntegerInput,
|
9 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
10 + | >
|
11 + | where
|
12 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
13 + | B::Data: Send,
|
14 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
15 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
16 + | {
|
17 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
18 + | Ok({
|
19 + | /* RustType.kt:534 */
|
20 + | #[allow(unused_mut)]
|
21 + | /* ServerHttpBoundProtocolGenerator.kt:759 */
|
22 + | let mut input = crate::input::malformed_integer_input::Builder::default();
|
23 + | /* RustType.kt:534 */
|
24 + | #[allow(unused_variables)]
|
25 + | /* ServerHttpBoundProtocolGenerator.kt:764 */
|
26 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
27 + | uri, headers, body, ..
|
28 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
29 + | /* ServerHttpBoundProtocolGenerator.kt:801 */
|
30 + | let bytes = ::hyper::body::to_bytes(body).await?;
|
31 + | /* ServerHttpBoundProtocolGenerator.kt:825 */
|
32 + | if !bytes.is_empty() {
|
33 + | /* ServerHttpBoundProtocolGenerator.kt:826 */
|
34 + | ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
|
35 + | &headers,
|
36 + | Some("application/json"),
|
37 + | )?;
|
38 + | input = crate::protocol_serde::shape_malformed_integer::de_malformed_integer(
|
39 + | bytes.as_ref(),
|
40 + | input,
|
41 + | )?;
|
42 + | /* ServerHttpBoundProtocolGenerator.kt:825 */
|
43 + | }
|
44 + | /* ServerHttpBoundProtocolGenerator.kt:856 */
|
45 + | if let Some(value) =
|
46 + | crate::protocol_serde::shape_malformed_integer_input::de_integer_in_header_header(
|
47 + | &headers,
|
48 + | )?
|
49 + | {
|
50 + | input = input.set_integer_in_header(Some(value))
|
51 + | }
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:1134 */
|
53 + | let input_string = uri.path();
|
54 + | /* ServerHttpBoundProtocolGenerator.kt:1146 */
|
55 + | let (input_string, (_, m1)) =
|
56 + | ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
|
57 + | ::nom::sequence::preceded(
|
58 + | ::nom::bytes::complete::tag("/"),
|
59 + | ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>(
|
60 + | "MalformedInteger",
|
61 + | ),
|
62 + | ),
|
63 + | ::nom::sequence::preceded(
|
64 + | ::nom::bytes::complete::tag("/"),
|
65 + | ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
|
66 + | ::nom::bytes::complete::take_until("/"),
|
67 + | ::nom::combinator::rest,
|
68 + | )),
|
69 + | ),
|
70 + | ))(input_string)?;
|
71 + | debug_assert_eq!("", input_string);
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:1157 */
|
73 + | input = input.set_integer_in_path(
|
74 + | crate::protocol_serde::shape_malformed_integer_input::de_integer_in_path(m1)?,
|
75 + | );
|
76 + | /* ServerHttpBoundProtocolGenerator.kt:1221 */
|
77 + | let query_string = uri.query().unwrap_or("");
|
78 + | let pairs = ::form_urlencoded::parse(query_string.as_bytes());
|
79 + | /* ServerHttpBoundProtocolGenerator.kt:1247 */
|
80 + | let mut integer_in_query_seen = false;
|
81 + | /* ServerHttpBoundProtocolGenerator.kt:1253 */
|
82 + | for (k, v) in pairs {
|
83 + | /* ServerHttpBoundProtocolGenerator.kt:1257 */
|
84 + | if !integer_in_query_seen && k == "integerInQuery" {
|
85 + | input = input.set_integer_in_query(
|
86 + | crate::protocol_serde::shape_malformed_integer_input::de_integer_in_query(&v)?,
|
87 + | );
|
88 + | integer_in_query_seen = true;
|
89 + | }
|
90 + | /* ServerHttpBoundProtocolGenerator.kt:1253 */
|
91 + | }
|
92 + | /* ServerHttpBoundProtocolGenerator.kt:896 */
|
93 + | input.build()?
|
94 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
95 + | })
|
96 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
97 + | }
|
98 + |
|
99 + | /* RustType.kt:534 */
|
100 + | #[allow(clippy::unnecessary_wraps)]
|
101 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
102 + | pub fn ser_malformed_integer_http_response(
|
103 + | #[allow(unused_variables)] output: crate::output::MalformedIntegerOutput,
|
104 + | ) -> std::result::Result<
|
105 + | ::aws_smithy_legacy_http_server::response::Response,
|
106 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
107 + | > {
|
108 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
109 + | Ok({
|
110 + | /* RustType.kt:534 */
|
111 + | #[allow(unused_mut)]
|
112 + | /* ServerHttpBoundProtocolGenerator.kt:547 */
|
113 + | let mut builder = ::http::Response::builder();
|
114 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
115 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
116 + | builder,
|
117 + | ::http::header::CONTENT_TYPE,
|
118 + | "application/json",
|
119 + | );
|
120 + | /* ServerHttpBoundProtocolGenerator.kt:718 */
|
121 + | let http_status: u16 = 200;
|
122 + | builder = builder.status(http_status);
|
123 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
124 + | let payload =
|
125 + | /* HttpBoundProtocolPayloadGenerator.kt:233 */""
|
126 + | /* ServerHttpBoundProtocolGenerator.kt:597 */;
|
127 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
128 + | let content_length = payload.len();
|
129 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
130 + | builder,
|
131 + | ::http::header::CONTENT_LENGTH,
|
132 + | content_length,
|
133 + | );
|
134 + | /* ServerHttpBoundProtocolGenerator.kt:603 */
|
135 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
136 + | /* ServerHttpBoundProtocolGenerator.kt:611 */
|
137 + | builder.body(body)?
|
138 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
139 + | })
|
140 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
141 + | }
|
142 + |
|
143 + | /* RustType.kt:534 */
|
144 + | #[allow(clippy::unnecessary_wraps)]
|
145 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
146 + | pub fn ser_malformed_integer_http_error(
|
147 + | error: &crate::error::MalformedIntegerError,
|
148 + | ) -> std::result::Result<
|
149 + | ::aws_smithy_legacy_http_server::response::Response,
|
150 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
151 + | > {
|
152 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
153 + | Ok({
|
154 + | /* ServerHttpBoundProtocolGenerator.kt:492 */
|
155 + | match error {
|
156 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
157 + | crate::error::MalformedIntegerError::ValidationException(output) => {
|
158 + | /* ServerHttpBoundProtocolGenerator.kt:501 */
|
159 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
160 + | /* RustType.kt:534 */
|
161 + | #[allow(unused_mut)]
|
162 + | /* ServerHttpBoundProtocolGenerator.kt:511 */
|
163 + | let mut builder = ::http::Response::builder();
|
164 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
165 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
166 + | builder,
|
167 + | ::http::header::CONTENT_TYPE,
|
168 + | "application/json",
|
169 + | );
|
170 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
171 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
172 + | builder,
|
173 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
174 + | "ValidationException",
|
175 + | );
|
176 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
177 + | let content_length = payload.len();
|
178 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
179 + | builder,
|
180 + | ::http::header::CONTENT_LENGTH,
|
181 + | content_length,
|
182 + | );
|
183 + | /* ServerHttpBoundProtocolGenerator.kt:528 */
|
184 + | builder
|
185 + | .status(400)
|
186 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
187 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
188 + | } /* ServerHttpBoundProtocolGenerator.kt:492 */
|
189 + | }
|
190 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
191 + | })
|
192 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
193 + | }
|
194 + |
|
195 + | /* JsonParserGenerator.kt:148 */
|
196 + | pub(crate) fn de_malformed_integer(
|
197 + | value: &[u8],
|
198 + | mut builder: crate::input::malformed_integer_input::Builder,
|
199 + | ) -> ::std::result::Result<
|
200 + | crate::input::malformed_integer_input::Builder,
|
201 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
202 + | > {
|
203 + | /* JsonParserGenerator.kt:153 */
|
204 + | let mut tokens_owned =
|
205 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
206 + | .peekable();
|
207 + | let tokens = &mut tokens_owned;
|
208 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
209 + | /* JsonParserGenerator.kt:684 */
|
210 + | loop {
|
211 + | /* JsonParserGenerator.kt:685 */
|
212 + | match tokens.next().transpose()? {
|
213 + | /* JsonParserGenerator.kt:686 */
|
214 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
215 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
216 + | /* JsonParserGenerator.kt:260 */
|
217 + | match key.to_unescaped()?.as_ref() {
|
218 + | /* JsonParserGenerator.kt:262 */
|
219 + | "integerInBody" => {
|
220 + | /* JsonParserGenerator.kt:272 */
|
221 + | builder = builder.set_integer_in_body(
|
222 + | /* JsonParserGenerator.kt:365 */
|
223 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
224 + | tokens.next(),
|
225 + | )?
|
226 + | .map(i32::try_from)
|
227 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
228 + | );
|
229 + | /* JsonParserGenerator.kt:262 */
|
230 + | }
|
231 + | /* JsonParserGenerator.kt:290 */
|
232 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
233 + | }
|
234 + | /* JsonParserGenerator.kt:686 */
|
235 + | }
|
236 + | /* JsonParserGenerator.kt:695 */
|
237 + | other => {
|
238 + | return Err(
|
239 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
240 + | "expected object key or end object, found: {other:?}"
|
241 + | )),
|
242 + | )
|
243 + | } /* JsonParserGenerator.kt:685 */
|
244 + | }
|
245 + | /* JsonParserGenerator.kt:684 */
|
246 + | }
|
247 + | /* JsonParserGenerator.kt:250 */
|
248 + | if tokens.next().is_some() {
|
249 + | /* JsonParserGenerator.kt:251 */
|
250 + | return Err(
|
251 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
252 + | "found more JSON tokens after completing parsing",
|
253 + | ),
|
254 + | );
|
255 + | /* JsonParserGenerator.kt:250 */
|
256 + | }
|
257 + | /* JsonParserGenerator.kt:163 */
|
258 + | Ok(builder)
|
259 + | /* JsonParserGenerator.kt:148 */
|
260 + | }
|