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_test_body_structure_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::TestBodyStructureInput,
|
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::test_body_structure_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_test_body_structure::de_test_body_structure(
|
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_test_body_structure_input::de_test_id_header(&headers)?
|
47 + | {
|
48 + | input = input.set_test_id(Some(value))
|
49 + | }
|
50 + | /* ServerHttpBoundProtocolGenerator.kt:896 */
|
51 + | input.build()
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:424 */
|
53 + | })
|
54 + | /* ServerHttpBoundProtocolGenerator.kt:408 */
|
55 + | }
|
56 + |
|
57 + | /* RustType.kt:534 */
|
58 + | #[allow(clippy::unnecessary_wraps)]
|
59 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
60 + | pub fn ser_test_body_structure_http_response(
|
61 + | #[allow(unused_variables)] output: crate::output::TestBodyStructureOutput,
|
62 + | ) -> std::result::Result<
|
63 + | ::aws_smithy_legacy_http_server::response::Response,
|
64 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
65 + | > {
|
66 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
67 + | Ok({
|
68 + | /* RustType.kt:534 */
|
69 + | #[allow(unused_mut)]
|
70 + | /* ServerHttpBoundProtocolGenerator.kt:547 */
|
71 + | let mut builder = ::http::Response::builder();
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:665 */
|
73 + | builder =
|
74 + | crate::protocol_serde::shape_test_body_structure::ser_test_body_structure_headers(
|
75 + | &output, builder,
|
76 + | )?;
|
77 + | /* ServerHttpBoundProtocolGenerator.kt:633 */
|
78 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
79 + | builder,
|
80 + | ::http::header::CONTENT_TYPE,
|
81 + | "application/json",
|
82 + | );
|
83 + | /* ServerHttpBoundProtocolGenerator.kt:718 */
|
84 + | let http_status: u16 = 200;
|
85 + | builder = builder.status(http_status);
|
86 + | /* ServerHttpBoundProtocolGenerator.kt:597 */
|
87 + | let payload =
|
88 + | /* HttpBoundProtocolPayloadGenerator.kt:235 */crate::protocol_serde::shape_test_body_structure_output::ser_test_body_structure_output_output_output(&output)?
|
89 + | /* ServerHttpBoundProtocolGenerator.kt:597 */;
|
90 + | /* ServerHttpBoundProtocolGenerator.kt:699 */
|
91 + | let content_length = payload.len();
|
92 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
93 + | builder,
|
94 + | ::http::header::CONTENT_LENGTH,
|
95 + | content_length,
|
96 + | );
|
97 + | /* ServerHttpBoundProtocolGenerator.kt:603 */
|
98 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
99 + | /* ServerHttpBoundProtocolGenerator.kt:611 */
|
100 + | builder.body(body)?
|
101 + | /* ServerHttpBoundProtocolGenerator.kt:457 */
|
102 + | })
|
103 + | /* ServerHttpBoundProtocolGenerator.kt:445 */
|
104 + | }
|
105 + |
|
106 + | /* JsonParserGenerator.kt:148 */
|
107 + | pub(crate) fn de_test_body_structure(
|
108 + | value: &[u8],
|
109 + | mut builder: crate::input::test_body_structure_input::Builder,
|
110 + | ) -> ::std::result::Result<
|
111 + | crate::input::test_body_structure_input::Builder,
|
112 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
113 + | > {
|
114 + | /* JsonParserGenerator.kt:153 */
|
115 + | let mut tokens_owned =
|
116 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
117 + | .peekable();
|
118 + | let tokens = &mut tokens_owned;
|
119 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
120 + | /* JsonParserGenerator.kt:684 */
|
121 + | loop {
|
122 + | /* JsonParserGenerator.kt:685 */
|
123 + | match tokens.next().transpose()? {
|
124 + | /* JsonParserGenerator.kt:686 */
|
125 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
126 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
127 + | /* JsonParserGenerator.kt:260 */
|
128 + | match key.to_unescaped()?.as_ref() {
|
129 + | /* JsonParserGenerator.kt:262 */
|
130 + | "testConfig" => {
|
131 + | /* JsonParserGenerator.kt:272 */
|
132 + | builder = builder.set_test_config(
|
133 + | /* JsonParserGenerator.kt:544 */crate::protocol_serde::shape_test_config::de_test_config(tokens)?
|
134 + | /* JsonParserGenerator.kt:272 */);
|
135 + | /* JsonParserGenerator.kt:262 */
|
136 + | }
|
137 + | /* JsonParserGenerator.kt:290 */
|
138 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?, /* JsonParserGenerator.kt:260 */
|
139 + | }
|
140 + | /* JsonParserGenerator.kt:686 */
|
141 + | }
|
142 + | /* JsonParserGenerator.kt:695 */
|
143 + | other => {
|
144 + | return Err(
|
145 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
146 + | "expected object key or end object, found: {other:?}"
|
147 + | )),
|
148 + | )
|
149 + | } /* JsonParserGenerator.kt:685 */
|
150 + | }
|
151 + | /* JsonParserGenerator.kt:684 */
|
152 + | }
|
153 + | /* JsonParserGenerator.kt:250 */
|
154 + | if tokens.next().is_some() {
|
155 + | /* JsonParserGenerator.kt:251 */
|
156 + | return Err(
|
157 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
158 + | "found more JSON tokens after completing parsing",
|
159 + | ),
|
160 + | );
|
161 + | /* JsonParserGenerator.kt:250 */
|
162 + | }
|
163 + | /* JsonParserGenerator.kt:163 */
|
164 + | Ok(builder)
|
165 + | /* JsonParserGenerator.kt:148 */
|
166 + | }
|
167 + |
|
168 + | /* HttpBindingGenerator.kt:565 */
|
169 + | pub fn ser_test_body_structure_headers(
|
170 + | input: &crate::output::TestBodyStructureOutput,
|
171 + | mut builder: ::http::response::Builder,
|
172 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
173 + | {
|
174 + | /* HttpBindingGenerator.kt:615 */
|
175 + | if let ::std::option::Option::Some(inner_1) = &input.test_id {
|
176 + | /* HttpBindingGenerator.kt:727 */
|
177 + | let formatted_2 = inner_1.as_str();
|
178 + | /* HttpBindingGenerator.kt:728 */
|
179 + | if !formatted_2.is_empty() {
|
180 + | /* HttpBindingGenerator.kt:729 */
|
181 + | let header_value = formatted_2;
|
182 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
183 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
184 + | "test_id",
|
185 + | format!(
|
186 + | "`{}` cannot be used as a header value: {}",
|
187 + | &header_value, err
|
188 + | ),
|
189 + | )
|
190 + | })?;
|
191 + | builder = builder.header("x-amz-test-id", header_value);
|
192 + | /* HttpBindingGenerator.kt:728 */
|
193 + | }
|
194 + | /* HttpBindingGenerator.kt:615 */
|
195 + | }
|
196 + | /* HttpBindingGenerator.kt:578 */
|
197 + | Ok(builder)
|
198 + | /* HttpBindingGenerator.kt:565 */
|
199 + | }
|