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