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_long_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::MalformedLongInput,
|
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_long_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_long::de_malformed_long(
|
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_long_input::de_long_in_header_header(&headers)?
|
47 + | {
|
48 + | input = input.set_long_in_header(Some(value))
|
49 + | }
|
50 + | /* ServerHttpBoundProtocolGenerator.kt:1134 */
|
51 + | let input_string = uri.path();
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:1146 */
|
53 + | let (input_string, (_, m1)) =
|
54 + | ::nom::sequence::tuple::<_, _, ::nom::error::Error<&str>, _>((
|
55 + | ::nom::sequence::preceded(
|
56 + | ::nom::bytes::complete::tag("/"),
|
57 + | ::nom::bytes::complete::tag::<_, _, ::nom::error::Error<&str>>("MalformedLong"),
|
58 + | ),
|
59 + | ::nom::sequence::preceded(
|
60 + | ::nom::bytes::complete::tag("/"),
|
61 + | ::nom::branch::alt::<_, _, ::nom::error::Error<&str>, _>((
|
62 + | ::nom::bytes::complete::take_until("/"),
|
63 + | ::nom::combinator::rest,
|
64 + | )),
|
65 + | ),
|
66 + | ))(input_string)?;
|
67 + | debug_assert_eq!("", input_string);
|
68 + | /* ServerHttpBoundProtocolGenerator.kt:1157 */
|
69 + | input = input.set_long_in_path(
|
70 + | crate::protocol_serde::shape_malformed_long_input::de_long_in_path(m1)?,
|
71 + | );
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:1221 */
|
73 + | let query_string = uri.query().unwrap_or("");
|
74 + | let pairs = ::form_urlencoded::parse(query_string.as_bytes());
|
75 + | /* ServerHttpBoundProtocolGenerator.kt:1247 */
|
76 + | let mut long_in_query_seen = false;
|
77 + | /* ServerHttpBoundProtocolGenerator.kt:1253 */
|
78 + | for (k, v) in pairs {
|
79 + | /* ServerHttpBoundProtocolGenerator.kt:1257 */
|
80 + | if !long_in_query_seen && k == "longInQuery" {
|
81 + | input = input.set_long_in_query(
|
82 + | crate::protocol_serde::shape_malformed_long_input::de_long_in_query(&v)?,
|
83 + | );
|
84 + | long_in_query_seen = true;
|
85 + | }
|
86 + | /* ServerHttpBoundProtocolGenerator.kt:1253 */
|
87 + | }
|
88 + | /* ServerHttpBoundProtocolGenerator.kt:896 */
|
89 + | input.build()?
|
90 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
91 + | })
|
92 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
93 + | }
|
94 + |
|
95 + | /* RustType.kt:534 */
|
96 + | #[allow(clippy::unnecessary_wraps)]
|
97 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
98 + | pub fn ser_malformed_long_http_response(
|
99 + | #[allow(unused_variables)] output: crate::output::MalformedLongOutput,
|
100 + | ) -> std::result::Result<
|
101 + | ::aws_smithy_legacy_http_server::response::Response,
|
102 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
103 + | > {
|
104 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
105 + | Ok({
|
106 + | /* RustType.kt:534 */
|
107 + | #[allow(unused_mut)]
|
108 + | /* ServerHttpBoundProtocolGenerator.kt:547 */
|
109 + | let mut builder = ::http::Response::builder();
|
110 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
111 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
112 + | builder,
|
113 + | ::http::header::CONTENT_TYPE,
|
114 + | "application/json",
|
115 + | );
|
116 + | /* ServerHttpBoundProtocolGenerator.kt:718 */
|
117 + | let http_status: u16 = 200;
|
118 + | builder = builder.status(http_status);
|
119 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
120 + | let payload =
|
121 + | /* HttpBoundProtocolPayloadGenerator.kt:233 */""
|
122 + | /* ServerHttpBoundProtocolGenerator.kt:597 */;
|
123 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
124 + | let content_length = payload.len();
|
125 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
126 + | builder,
|
127 + | ::http::header::CONTENT_LENGTH,
|
128 + | content_length,
|
129 + | );
|
130 + | /* ServerHttpBoundProtocolGenerator.kt:603 */
|
131 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
132 + | /* ServerHttpBoundProtocolGenerator.kt:611 */
|
133 + | builder.body(body)?
|
134 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
135 + | })
|
136 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
137 + | }
|
138 + |
|
139 + | /* RustType.kt:534 */
|
140 + | #[allow(clippy::unnecessary_wraps)]
|
141 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
142 + | pub fn ser_malformed_long_http_error(
|
143 + | error: &crate::error::MalformedLongError,
|
144 + | ) -> std::result::Result<
|
145 + | ::aws_smithy_legacy_http_server::response::Response,
|
146 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
147 + | > {
|
148 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
149 + | Ok({
|
150 + | /* ServerHttpBoundProtocolGenerator.kt:492 */
|
151 + | match error {
|
152 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
153 + | crate::error::MalformedLongError::ValidationException(output) => {
|
154 + | /* ServerHttpBoundProtocolGenerator.kt:501 */
|
155 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
156 + | /* RustType.kt:534 */
|
157 + | #[allow(unused_mut)]
|
158 + | /* ServerHttpBoundProtocolGenerator.kt:511 */
|
159 + | let mut builder = ::http::Response::builder();
|
160 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
161 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
162 + | builder,
|
163 + | ::http::header::CONTENT_TYPE,
|
164 + | "application/json",
|
165 + | );
|
166 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
167 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
168 + | builder,
|
169 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
170 + | "ValidationException",
|
171 + | );
|
172 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
173 + | let content_length = payload.len();
|
174 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
175 + | builder,
|
176 + | ::http::header::CONTENT_LENGTH,
|
177 + | content_length,
|
178 + | );
|
179 + | /* ServerHttpBoundProtocolGenerator.kt:528 */
|
180 + | builder
|
181 + | .status(400)
|
182 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
183 + | /* ServerHttpBoundProtocolGenerator.kt:500 */
|
184 + | } /* ServerHttpBoundProtocolGenerator.kt:492 */
|
185 + | }
|
186 + | /* ServerHttpBoundProtocolGenerator.kt:476 */
|
187 + | })
|
188 + | /* ServerHttpBoundProtocolGenerator.kt:471 */
|
189 + | }
|
190 + |
|
191 + | /* JsonParserGenerator.kt:148 */
|
192 + | pub(crate) fn de_malformed_long(
|
193 + | value: &[u8],
|
194 + | mut builder: crate::input::malformed_long_input::Builder,
|
195 + | ) -> ::std::result::Result<
|
196 + | crate::input::malformed_long_input::Builder,
|
197 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
198 + | > {
|
199 + | /* JsonParserGenerator.kt:153 */
|
200 + | let mut tokens_owned =
|
201 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
202 + | .peekable();
|
203 + | let tokens = &mut tokens_owned;
|
204 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
205 + | /* JsonParserGenerator.kt:684 */
|
206 + | loop {
|
207 + | /* JsonParserGenerator.kt:685 */
|
208 + | match tokens.next().transpose()? {
|
209 + | /* JsonParserGenerator.kt:686 */
|
210 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
211 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
212 + | /* JsonParserGenerator.kt:260 */
|
213 + | match key.to_unescaped()?.as_ref() {
|
214 + | /* JsonParserGenerator.kt:262 */
|
215 + | "longInBody" => {
|
216 + | /* JsonParserGenerator.kt:272 */
|
217 + | builder = builder.set_long_in_body(
|
218 + | /* JsonParserGenerator.kt:365 */
|
219 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
220 + | tokens.next(),
|
221 + | )?
|
222 + | .map(i64::try_from)
|
223 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
224 + | );
|
225 + | /* JsonParserGenerator.kt:262 */
|
226 + | }
|
227 + | /* JsonParserGenerator.kt:290 */
|
228 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
229 + | }
|
230 + | /* JsonParserGenerator.kt:686 */
|
231 + | }
|
232 + | /* JsonParserGenerator.kt:695 */
|
233 + | other => {
|
234 + | return Err(
|
235 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
236 + | "expected object key or end object, found: {other:?}"
|
237 + | )),
|
238 + | )
|
239 + | } /* JsonParserGenerator.kt:685 */
|
240 + | }
|
241 + | /* JsonParserGenerator.kt:684 */
|
242 + | }
|
243 + | /* JsonParserGenerator.kt:250 */
|
244 + | if tokens.next().is_some() {
|
245 + | /* JsonParserGenerator.kt:251 */
|
246 + | return Err(
|
247 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
248 + | "found more JSON tokens after completing parsing",
|
249 + | ),
|
250 + | );
|
251 + | /* JsonParserGenerator.kt:250 */
|
252 + | }
|
253 + | /* JsonParserGenerator.kt:163 */
|
254 + | Ok(builder)
|
255 + | /* JsonParserGenerator.kt:148 */
|
256 + | }
|