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_simple_scalar_properties_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::SimpleScalarPropertiesInput,
|
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::simple_scalar_properties_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 =
|
39 + | crate::protocol_serde::shape_simple_scalar_properties::de_simple_scalar_properties(
|
40 + | bytes.as_ref(),
|
41 + | input,
|
42 + | )?;
|
43 + | /* ServerHttpBoundProtocolGenerator.kt:825 */
|
44 + | }
|
45 + | /* ServerHttpBoundProtocolGenerator.kt:856 */
|
46 + | if let Some(value) =
|
47 + | crate::protocol_serde::shape_simple_scalar_properties_input::de_foo_header(&headers)?
|
48 + | {
|
49 + | input = input.set_foo(Some(value))
|
50 + | }
|
51 + | /* ServerHttpBoundProtocolGenerator.kt:896 */
|
52 + | input.build()
|
53 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
54 + | })
|
55 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
56 + | }
|
57 + |
|
58 + | /* RustType.kt:534 */
|
59 + | #[allow(clippy::unnecessary_wraps)]
|
60 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
61 + | pub fn ser_simple_scalar_properties_http_response(
|
62 + | #[allow(unused_variables)] output: crate::output::SimpleScalarPropertiesOutput,
|
63 + | ) -> std::result::Result<
|
64 + | ::aws_smithy_legacy_http_server::response::Response,
|
65 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
66 + | > {
|
67 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
68 + | Ok({
|
69 + | /* RustType.kt:534 */
|
70 + | #[allow(unused_mut)]
|
71 + | /* ServerHttpBoundProtocolGenerator.kt:547 */
|
72 + | let mut builder = ::http::Response::builder();
|
73 + | /* ServerHttpBoundProtocolGenerator.kt:665 */
|
74 + | builder = crate::protocol_serde::shape_simple_scalar_properties::ser_simple_scalar_properties_headers(&output, builder)?;
|
75 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
76 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
77 + | builder,
|
78 + | ::http::header::CONTENT_TYPE,
|
79 + | "application/json",
|
80 + | );
|
81 + | /* ServerHttpBoundProtocolGenerator.kt:718 */
|
82 + | let http_status: u16 = 200;
|
83 + | builder = builder.status(http_status);
|
84 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
85 + | let payload =
|
86 + | /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_simple_scalar_properties_output::ser_simple_scalar_properties_output_output_output(&output)?
|
87 + | /* ServerHttpBoundProtocolGenerator.kt:597 */;
|
88 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
89 + | let content_length = payload.len();
|
90 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
91 + | builder,
|
92 + | ::http::header::CONTENT_LENGTH,
|
93 + | content_length,
|
94 + | );
|
95 + | /* ServerHttpBoundProtocolGenerator.kt:603 */
|
96 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
97 + | /* ServerHttpBoundProtocolGenerator.kt:611 */
|
98 + | builder.body(body)?
|
99 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
100 + | })
|
101 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
102 + | }
|
103 + |
|
104 + | /* JsonParserGenerator.kt:148 */
|
105 + | pub(crate) fn de_simple_scalar_properties(
|
106 + | value: &[u8],
|
107 + | mut builder: crate::input::simple_scalar_properties_input::Builder,
|
108 + | ) -> ::std::result::Result<
|
109 + | crate::input::simple_scalar_properties_input::Builder,
|
110 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
111 + | > {
|
112 + | /* JsonParserGenerator.kt:153 */
|
113 + | let mut tokens_owned =
|
114 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
115 + | .peekable();
|
116 + | let tokens = &mut tokens_owned;
|
117 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
118 + | /* JsonParserGenerator.kt:684 */
|
119 + | loop {
|
120 + | /* JsonParserGenerator.kt:685 */
|
121 + | match tokens.next().transpose()? {
|
122 + | /* JsonParserGenerator.kt:686 */
|
123 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
124 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
125 + | /* JsonParserGenerator.kt:260 */
|
126 + | match key.to_unescaped()?.as_ref() {
|
127 + | /* JsonParserGenerator.kt:262 */
|
128 + | "byteValue" => {
|
129 + | /* JsonParserGenerator.kt:272 */
|
130 + | builder = builder.set_byte_value(
|
131 + | /* JsonParserGenerator.kt:365 */
|
132 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
133 + | tokens.next(),
|
134 + | )?
|
135 + | .map(i8::try_from)
|
136 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
137 + | );
|
138 + | /* JsonParserGenerator.kt:262 */
|
139 + | }
|
140 + | /* JsonParserGenerator.kt:262 */
|
141 + | "DoubleDribble" => {
|
142 + | /* JsonParserGenerator.kt:272 */
|
143 + | builder = builder.set_double_value(
|
144 + | /* JsonParserGenerator.kt:363 */
|
145 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
146 + | tokens.next(),
|
147 + | )?
|
148 + | .map(|v| v.to_f64_lossy()), /* JsonParserGenerator.kt:272 */
|
149 + | );
|
150 + | /* JsonParserGenerator.kt:262 */
|
151 + | }
|
152 + | /* JsonParserGenerator.kt:262 */
|
153 + | "falseBooleanValue" => {
|
154 + | /* JsonParserGenerator.kt:272 */
|
155 + | builder = builder.set_false_boolean_value(
|
156 + | /* JsonParserGenerator.kt:298 */
|
157 + | ::aws_smithy_json::deserialize::token::expect_bool_or_null(
|
158 + | tokens.next(),
|
159 + | )?, /* JsonParserGenerator.kt:272 */
|
160 + | );
|
161 + | /* JsonParserGenerator.kt:262 */
|
162 + | }
|
163 + | /* JsonParserGenerator.kt:262 */
|
164 + | "floatValue" => {
|
165 + | /* JsonParserGenerator.kt:272 */
|
166 + | builder = builder.set_float_value(
|
167 + | /* JsonParserGenerator.kt:361 */
|
168 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
169 + | tokens.next(),
|
170 + | )?
|
171 + | .map(|v| v.to_f32_lossy()), /* JsonParserGenerator.kt:272 */
|
172 + | );
|
173 + | /* JsonParserGenerator.kt:262 */
|
174 + | }
|
175 + | /* JsonParserGenerator.kt:262 */
|
176 + | "integerValue" => {
|
177 + | /* JsonParserGenerator.kt:272 */
|
178 + | builder = builder.set_integer_value(
|
179 + | /* JsonParserGenerator.kt:365 */
|
180 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
181 + | tokens.next(),
|
182 + | )?
|
183 + | .map(i32::try_from)
|
184 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
185 + | );
|
186 + | /* JsonParserGenerator.kt:262 */
|
187 + | }
|
188 + | /* JsonParserGenerator.kt:262 */
|
189 + | "longValue" => {
|
190 + | /* JsonParserGenerator.kt:272 */
|
191 + | builder = builder.set_long_value(
|
192 + | /* JsonParserGenerator.kt:365 */
|
193 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
194 + | tokens.next(),
|
195 + | )?
|
196 + | .map(i64::try_from)
|
197 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
198 + | );
|
199 + | /* JsonParserGenerator.kt:262 */
|
200 + | }
|
201 + | /* JsonParserGenerator.kt:262 */
|
202 + | "shortValue" => {
|
203 + | /* JsonParserGenerator.kt:272 */
|
204 + | builder = builder.set_short_value(
|
205 + | /* JsonParserGenerator.kt:365 */
|
206 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
207 + | tokens.next(),
|
208 + | )?
|
209 + | .map(i16::try_from)
|
210 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
211 + | );
|
212 + | /* JsonParserGenerator.kt:262 */
|
213 + | }
|
214 + | /* JsonParserGenerator.kt:262 */
|
215 + | "stringValue" => {
|
216 + | /* JsonParserGenerator.kt:272 */
|
217 + | builder = builder.set_string_value(
|
218 + | /* JsonParserGenerator.kt:354 */
|
219 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(
|
220 + | tokens.next(),
|
221 + | )?
|
222 + | .map(|s|
|
223 + | /* JsonParserGenerator.kt:339 */s.to_unescaped().map(|u|
|
224 + | /* JsonParserGenerator.kt:348 */u.into_owned()
|
225 + | /* JsonParserGenerator.kt:339 */) /* JsonParserGenerator.kt:354 */)
|
226 + | .transpose()?, /* JsonParserGenerator.kt:272 */
|
227 + | );
|
228 + | /* JsonParserGenerator.kt:262 */
|
229 + | }
|
230 + | /* JsonParserGenerator.kt:262 */
|
231 + | "trueBooleanValue" => {
|
232 + | /* JsonParserGenerator.kt:272 */
|
233 + | builder = builder.set_true_boolean_value(
|
234 + | /* JsonParserGenerator.kt:298 */
|
235 + | ::aws_smithy_json::deserialize::token::expect_bool_or_null(
|
236 + | tokens.next(),
|
237 + | )?, /* JsonParserGenerator.kt:272 */
|
238 + | );
|
239 + | /* JsonParserGenerator.kt:262 */
|
240 + | }
|
241 + | /* JsonParserGenerator.kt:290 */
|
242 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
243 + | }
|
244 + | /* JsonParserGenerator.kt:686 */
|
245 + | }
|
246 + | /* JsonParserGenerator.kt:695 */
|
247 + | other => {
|
248 + | return Err(
|
249 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
250 + | "expected object key or end object, found: {other:?}"
|
251 + | )),
|
252 + | )
|
253 + | } /* JsonParserGenerator.kt:685 */
|
254 + | }
|
255 + | /* JsonParserGenerator.kt:684 */
|
256 + | }
|
257 + | /* JsonParserGenerator.kt:250 */
|
258 + | if tokens.next().is_some() {
|
259 + | /* JsonParserGenerator.kt:251 */
|
260 + | return Err(
|
261 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
262 + | "found more JSON tokens after completing parsing",
|
263 + | ),
|
264 + | );
|
265 + | /* JsonParserGenerator.kt:250 */
|
266 + | }
|
267 + | /* JsonParserGenerator.kt:163 */
|
268 + | Ok(builder)
|
269 + | /* JsonParserGenerator.kt:148 */
|
270 + | }
|
271 + |
|
272 + | /* HttpBindingGenerator.kt:565 */
|
273 + | pub fn ser_simple_scalar_properties_headers(
|
274 + | input: &crate::output::SimpleScalarPropertiesOutput,
|
275 + | mut builder: ::http::response::Builder,
|
276 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
277 + | {
|
278 + | /* HttpBindingGenerator.kt:615 */
|
279 + | if let ::std::option::Option::Some(inner_1) = &input.foo {
|
280 + | /* HttpBindingGenerator.kt:727 */
|
281 + | let formatted_2 = inner_1.as_str();
|
282 + | /* HttpBindingGenerator.kt:728 */
|
283 + | if !formatted_2.is_empty() {
|
284 + | /* HttpBindingGenerator.kt:729 */
|
285 + | let header_value = formatted_2;
|
286 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
287 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
288 + | "foo",
|
289 + | format!(
|
290 + | "`{}` cannot be used as a header value: {}",
|
291 + | &header_value, err
|
292 + | ),
|
293 + | )
|
294 + | })?;
|
295 + | builder = builder.header("X-Foo", header_value);
|
296 + | /* HttpBindingGenerator.kt:728 */
|
297 + | }
|
298 + | /* HttpBindingGenerator.kt:615 */
|
299 + | }
|
300 + | /* HttpBindingGenerator.kt:578 */
|
301 + | Ok(builder)
|
302 + | /* HttpBindingGenerator.kt:565 */
|
303 + | }
|