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