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