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:412 */
|
5 + | pub async fn de_duplex_stream_with_initial_messages_http_request<B>(
|
6 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
7 + | ) -> std::result::Result<
|
8 + | crate::input::DuplexStreamWithInitialMessagesInput,
|
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: Into<::aws_smithy_types::byte_stream::ByteStream>,
|
14 + | B::Data: Send,
|
15 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
16 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
17 + | {
|
18 + | /* ServerHttpBoundProtocolGenerator.kt:428 */
|
19 + | Ok({
|
20 + | /* RustType.kt:534 */
|
21 + | #[allow(unused_mut)]
|
22 + | /* ServerHttpBoundProtocolGenerator.kt:773 */
|
23 + | let mut input = crate::input::duplex_stream_with_initial_messages_input::Builder::default();
|
24 + | /* RustType.kt:534 */
|
25 + | #[allow(unused_variables)]
|
26 + | /* ServerHttpBoundProtocolGenerator.kt:778 */
|
27 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
28 + | uri, headers, body, ..
|
29 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
30 + | /* ServerHttpBoundProtocolGenerator.kt:870 */
|
31 + | if let Some(value) = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_initial_request_member_header(&headers)? {
|
32 + | input = input.set_initial_request_member(value)
|
33 + | }
|
34 + | /* ServerHttpBoundProtocolGenerator.kt:870 */
|
35 + | if let Some(value) = {
|
36 + | let mut receiver = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_stream_payload(&mut body.into().into_inner())?;
|
37 + | if let Some(_initial_event) = receiver
|
38 + | .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
|
39 + | .await
|
40 + | .map_err(
|
41 + | |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
|
42 + | #[allow(clippy::useless_conversion)]
|
43 + | format!("{ev_error}").into()
|
44 + | )
|
45 + | )? {
|
46 + |
|
47 + | }
|
48 + | Some(receiver)
|
49 + | } {
|
50 + | input = input.set_stream(value)
|
51 + | }
|
52 + | /* ServerHttpBoundProtocolGenerator.kt:910 */
|
53 + | input.build()?
|
54 + | /* ServerHttpBoundProtocolGenerator.kt:428 */
|
55 + | })
|
56 + | /* ServerHttpBoundProtocolGenerator.kt:412 */
|
57 + | }
|
58 + |
|
59 + | /* RustType.kt:534 */
|
60 + | #[allow(clippy::unnecessary_wraps)]
|
61 + | /* ServerHttpBoundProtocolGenerator.kt:449 */
|
62 + | pub fn ser_duplex_stream_with_initial_messages_http_response(
|
63 + | #[allow(unused_variables)] output: crate::output::DuplexStreamWithInitialMessagesOutput,
|
64 + | ) -> std::result::Result<
|
65 + | ::aws_smithy_legacy_http_server::response::Response,
|
66 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
67 + | > {
|
68 + | /* ServerHttpBoundProtocolGenerator.kt:461 */
|
69 + | Ok({
|
70 + | /* RustType.kt:534 */
|
71 + | #[allow(unused_mut)]
|
72 + | /* ServerHttpBoundProtocolGenerator.kt:551 */
|
73 + | let mut builder = ::http::Response::builder();
|
74 + | /* ServerHttpBoundProtocolGenerator.kt:679 */
|
75 + | builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(&output, builder)?;
|
76 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
77 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
78 + | builder,
|
79 + | ::http::header::CONTENT_TYPE,
|
80 + | "application/vnd.amazon.eventstream",
|
81 + | );
|
82 + | /* ServerHttpBoundProtocolGenerator.kt:732 */
|
83 + | let http_status: u16 = 200;
|
84 + | builder = builder.status(http_status);
|
85 + | /* ServerHttpBoundProtocolGenerator.kt:589 */
|
86 + | let body = ::aws_smithy_legacy_http_server::body::boxed(
|
87 + | ::aws_smithy_legacy_http_server::body::Body::wrap_stream(
|
88 + | /* ServerHttpBoundProtocolGenerator.kt:145 */
|
89 + | {
|
90 + | let error_marshaller =
|
91 + | crate::event_stream_serde::EventStreamErrorMarshaller::new();
|
92 + | let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
|
93 + | let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
|
94 + | output
|
95 + | .stream
|
96 + | .into_body_stream(marshaller, error_marshaller, signer)
|
97 + | }, /* ServerHttpBoundProtocolGenerator.kt:589 */
|
98 + | ),
|
99 + | );
|
100 + | /* ServerHttpBoundProtocolGenerator.kt:625 */
|
101 + | builder.body(body)?
|
102 + | /* ServerHttpBoundProtocolGenerator.kt:461 */
|
103 + | })
|
104 + | /* ServerHttpBoundProtocolGenerator.kt:449 */
|
105 + | }
|
106 + |
|
107 + | /* RustType.kt:534 */
|
108 + | #[allow(clippy::unnecessary_wraps)]
|
109 + | /* ServerHttpBoundProtocolGenerator.kt:475 */
|
110 + | pub fn ser_duplex_stream_with_initial_messages_http_error(
|
111 + | error: &crate::error::DuplexStreamWithInitialMessagesError,
|
112 + | ) -> std::result::Result<
|
113 + | ::aws_smithy_legacy_http_server::response::Response,
|
114 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
115 + | > {
|
116 + | /* ServerHttpBoundProtocolGenerator.kt:480 */
|
117 + | Ok({
|
118 + | /* ServerHttpBoundProtocolGenerator.kt:496 */
|
119 + | match error {
|
120 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
121 + | crate::error::DuplexStreamWithInitialMessagesError::ServiceUnavailableError(output) => {
|
122 + | /* ServerHttpBoundProtocolGenerator.kt:505 */
|
123 + | let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
|
124 + | /* RustType.kt:534 */
|
125 + | #[allow(unused_mut)]
|
126 + | /* ServerHttpBoundProtocolGenerator.kt:515 */
|
127 + | let mut builder = ::http::Response::builder();
|
128 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
129 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
130 + | builder,
|
131 + | ::http::header::CONTENT_TYPE,
|
132 + | "application/vnd.amazon.eventstream",
|
133 + | );
|
134 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
135 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
136 + | builder,
|
137 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
138 + | "ServiceUnavailableError",
|
139 + | );
|
140 + | /* ServerHttpBoundProtocolGenerator.kt:713 */
|
141 + | let content_length = payload.len();
|
142 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
143 + | builder,
|
144 + | ::http::header::CONTENT_LENGTH,
|
145 + | content_length,
|
146 + | );
|
147 + | /* ServerHttpBoundProtocolGenerator.kt:532 */
|
148 + | builder
|
149 + | .status(500)
|
150 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
151 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
152 + | }
|
153 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
154 + | crate::error::DuplexStreamWithInitialMessagesError::ValidationException(output) => {
|
155 + | /* ServerHttpBoundProtocolGenerator.kt:505 */
|
156 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
157 + | /* RustType.kt:534 */
|
158 + | #[allow(unused_mut)]
|
159 + | /* ServerHttpBoundProtocolGenerator.kt:515 */
|
160 + | let mut builder = ::http::Response::builder();
|
161 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
162 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
163 + | builder,
|
164 + | ::http::header::CONTENT_TYPE,
|
165 + | "application/vnd.amazon.eventstream",
|
166 + | );
|
167 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
168 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
169 + | builder,
|
170 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
171 + | "ValidationException",
|
172 + | );
|
173 + | /* ServerHttpBoundProtocolGenerator.kt:713 */
|
174 + | let content_length = payload.len();
|
175 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
176 + | builder,
|
177 + | ::http::header::CONTENT_LENGTH,
|
178 + | content_length,
|
179 + | );
|
180 + | /* ServerHttpBoundProtocolGenerator.kt:532 */
|
181 + | builder
|
182 + | .status(400)
|
183 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
184 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
185 + | }
|
186 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
187 + | crate::error::DuplexStreamWithInitialMessagesError::ErrorEvent(output) => {
|
188 + | /* ServerHttpBoundProtocolGenerator.kt:505 */
|
189 + | let payload =
|
190 + | crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
|
191 + | /* RustType.kt:534 */
|
192 + | #[allow(unused_mut)]
|
193 + | /* ServerHttpBoundProtocolGenerator.kt:515 */
|
194 + | let mut builder = ::http::Response::builder();
|
195 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
196 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
197 + | builder,
|
198 + | ::http::header::CONTENT_TYPE,
|
199 + | "application/vnd.amazon.eventstream",
|
200 + | );
|
201 + | /* ServerHttpBoundProtocolGenerator.kt:647 */
|
202 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
203 + | builder,
|
204 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
205 + | "ErrorEvent",
|
206 + | );
|
207 + | /* ServerHttpBoundProtocolGenerator.kt:713 */
|
208 + | let content_length = payload.len();
|
209 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
210 + | builder,
|
211 + | ::http::header::CONTENT_LENGTH,
|
212 + | content_length,
|
213 + | );
|
214 + | /* ServerHttpBoundProtocolGenerator.kt:532 */
|
215 + | builder
|
216 + | .status(400)
|
217 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
218 + | /* ServerHttpBoundProtocolGenerator.kt:504 */
|
219 + | } /* ServerHttpBoundProtocolGenerator.kt:496 */
|
220 + | }
|
221 + | /* ServerHttpBoundProtocolGenerator.kt:480 */
|
222 + | })
|
223 + | /* ServerHttpBoundProtocolGenerator.kt:475 */
|
224 + | }
|
225 + |
|
226 + | /* HttpBindingGenerator.kt:565 */
|
227 + | pub fn ser_duplex_stream_with_initial_messages_headers(
|
228 + | input: &crate::output::DuplexStreamWithInitialMessagesOutput,
|
229 + | mut builder: ::http::response::Builder,
|
230 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
231 + | {
|
232 + | /* SerializerUtil.kt:42 */
|
233 + | {
|
234 + | /* HttpBindingGenerator.kt:727 */
|
235 + | let formatted_1 = &input.initial_response_member.as_str();
|
236 + | /* HttpBindingGenerator.kt:728 */
|
237 + | if !formatted_1.is_empty() {
|
238 + | /* HttpBindingGenerator.kt:729 */
|
239 + | let header_value = formatted_1;
|
240 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
241 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
242 + | "initial_response_member",
|
243 + | format!(
|
244 + | "`{}` cannot be used as a header value: {}",
|
245 + | &header_value, err
|
246 + | ),
|
247 + | )
|
248 + | })?;
|
249 + | builder = builder.header("initial-response-member", header_value);
|
250 + | /* HttpBindingGenerator.kt:728 */
|
251 + | }
|
252 + | /* SerializerUtil.kt:42 */
|
253 + | }
|
254 + | /* HttpBindingGenerator.kt:578 */
|
255 + | Ok(builder)
|
256 + | /* HttpBindingGenerator.kt:565 */
|
257 + | }
|