1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_duplex_stream_with_initial_messages_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::DuplexStreamWithInitialMessagesInput,
|
7 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection,
|
8 + | >
|
9 + | where
|
10 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11 + | B: Into<::aws_smithy_types::byte_stream::ByteStream>,
|
12 + | B::Data: Send,
|
13 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection:
|
14 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
15 + | {
|
16 + | Ok({
|
17 + | #[allow(unused_mut)]
|
18 + | let mut input =
|
19 + | crate::input::duplex_stream_with_initial_messages_input_internal::Builder::default();
|
20 + | #[allow(unused_variables)]
|
21 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
22 + | uri, headers, body, ..
|
23 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
24 + | if let Some(value) = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_initial_request_member_header(&headers)? {
|
25 + | input = input.set_initial_request_member(value)
|
26 + | }
|
27 + | if let Some(value) = {
|
28 + | let mut receiver = crate::protocol_serde::shape_duplex_stream_with_initial_messages_input::de_stream_payload(&mut body.into().into_inner())?;
|
29 + | if let Some(_initial_event) = receiver
|
30 + | .try_recv_initial(::aws_smithy_legacy_http::event_stream::InitialMessageType::Request)
|
31 + | .await
|
32 + | .map_err(
|
33 + | |ev_error| ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::RequestRejection::ConstraintViolation(
|
34 + | #[allow(clippy::useless_conversion)]
|
35 + | format!("{ev_error}").into()
|
36 + | )
|
37 + | )? {
|
38 + |
|
39 + | }
|
40 + | Some(receiver)
|
41 + | } {
|
42 + | input = input.set_stream(value)
|
43 + | }
|
44 + | input.build()?
|
45 + | })
|
46 + | }
|
47 + |
|
48 + | #[allow(clippy::unnecessary_wraps)]
|
49 + | pub fn ser_duplex_stream_with_initial_messages_http_response(
|
50 + | #[allow(unused_variables)] output: crate::output::DuplexStreamWithInitialMessagesOutput,
|
51 + | ) -> std::result::Result<
|
52 + | ::aws_smithy_legacy_http_server::response::Response,
|
53 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
54 + | > {
|
55 + | Ok({
|
56 + | #[allow(unused_mut)]
|
57 + | let mut builder = ::http::Response::builder();
|
58 + | builder = crate::protocol_serde::shape_duplex_stream_with_initial_messages::ser_duplex_stream_with_initial_messages_headers(&output, builder)?;
|
59 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
60 + | builder,
|
61 + | ::http::header::CONTENT_TYPE,
|
62 + | "application/vnd.amazon.eventstream",
|
63 + | );
|
64 + | let http_status: u16 = 200;
|
65 + | builder = builder.status(http_status);
|
66 + | let body = ::aws_smithy_legacy_http_server::body::boxed(
|
67 + | ::aws_smithy_legacy_http_server::body::Body::wrap_stream({
|
68 + | let error_marshaller = crate::event_stream_serde::EventStreamErrorMarshaller::new();
|
69 + | let marshaller = crate::event_stream_serde::EventStreamMarshaller::new();
|
70 + | let signer = ::aws_smithy_eventstream::frame::NoOpSigner {};
|
71 + | output
|
72 + | .stream
|
73 + | .into_body_stream(marshaller, error_marshaller, signer)
|
74 + | }),
|
75 + | );
|
76 + | builder.body(body)?
|
77 + | })
|
78 + | }
|
79 + |
|
80 + | #[allow(clippy::unnecessary_wraps)]
|
81 + | pub fn ser_duplex_stream_with_initial_messages_http_error(
|
82 + | error: &crate::error::DuplexStreamWithInitialMessagesError,
|
83 + | ) -> std::result::Result<
|
84 + | ::aws_smithy_legacy_http_server::response::Response,
|
85 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
86 + | > {
|
87 + | Ok({
|
88 + | match error {
|
89 + | crate::error::DuplexStreamWithInitialMessagesError::ServiceUnavailableError(output) => {
|
90 + | let payload = crate::protocol_serde::shape_service_unavailable_error::ser_service_unavailable_error_error(output)?;
|
91 + | #[allow(unused_mut)]
|
92 + | let mut builder = ::http::Response::builder();
|
93 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
94 + | builder,
|
95 + | ::http::header::CONTENT_TYPE,
|
96 + | "application/vnd.amazon.eventstream",
|
97 + | );
|
98 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
99 + | builder,
|
100 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
101 + | "ServiceUnavailableError",
|
102 + | );
|
103 + | let content_length = payload.len();
|
104 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
105 + | builder,
|
106 + | ::http::header::CONTENT_LENGTH,
|
107 + | content_length,
|
108 + | );
|
109 + | builder
|
110 + | .status(500)
|
111 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
112 + | }
|
113 + | crate::error::DuplexStreamWithInitialMessagesError::ValidationException(output) => {
|
114 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
115 + | #[allow(unused_mut)]
|
116 + | let mut builder = ::http::Response::builder();
|
117 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
118 + | builder,
|
119 + | ::http::header::CONTENT_TYPE,
|
120 + | "application/vnd.amazon.eventstream",
|
121 + | );
|
122 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
123 + | builder,
|
124 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
125 + | "ValidationException",
|
126 + | );
|
127 + | let content_length = payload.len();
|
128 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
129 + | builder,
|
130 + | ::http::header::CONTENT_LENGTH,
|
131 + | content_length,
|
132 + | );
|
133 + | builder
|
134 + | .status(400)
|
135 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
136 + | }
|
137 + | crate::error::DuplexStreamWithInitialMessagesError::ErrorEvent(output) => {
|
138 + | let payload =
|
139 + | crate::protocol_serde::shape_error_event::ser_error_event_error(output)?;
|
140 + | #[allow(unused_mut)]
|
141 + | let mut builder = ::http::Response::builder();
|
142 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
143 + | builder,
|
144 + | ::http::header::CONTENT_TYPE,
|
145 + | "application/vnd.amazon.eventstream",
|
146 + | );
|
147 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
148 + | builder,
|
149 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
150 + | "ErrorEvent",
|
151 + | );
|
152 + | let content_length = payload.len();
|
153 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
154 + | builder,
|
155 + | ::http::header::CONTENT_LENGTH,
|
156 + | content_length,
|
157 + | );
|
158 + | builder
|
159 + | .status(400)
|
160 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
161 + | }
|
162 + | crate::error::DuplexStreamWithInitialMessagesError::InternalServerError(output) => {
|
163 + | let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
|
164 + | #[allow(unused_mut)]
|
165 + | let mut builder = ::http::Response::builder();
|
166 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
167 + | builder,
|
168 + | ::http::header::CONTENT_TYPE,
|
169 + | "application/vnd.amazon.eventstream",
|
170 + | );
|
171 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
172 + | builder,
|
173 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
174 + | "InternalServerError",
|
175 + | );
|
176 + | let content_length = payload.len();
|
177 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
178 + | builder,
|
179 + | ::http::header::CONTENT_LENGTH,
|
180 + | content_length,
|
181 + | );
|
182 + | builder
|
183 + | .status(500)
|
184 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
185 + | }
|
186 + | }
|
187 + | })
|
188 + | }
|
189 + |
|
190 + | pub fn ser_duplex_stream_with_initial_messages_headers(
|
191 + | input: &crate::output::DuplexStreamWithInitialMessagesOutput,
|
192 + | mut builder: ::http::response::Builder,
|
193 + | ) -> std::result::Result<::http::response::Builder, ::aws_smithy_types::error::operation::BuildError>
|
194 + | {
|
195 + | {
|
196 + | let formatted_1 = &input.initial_response_member.as_str();
|
197 + | if !formatted_1.is_empty() {
|
198 + | let header_value = formatted_1;
|
199 + | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
200 + | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
201 + | "initial_response_member",
|
202 + | format!(
|
203 + | "`{}` cannot be used as a header value: {}",
|
204 + | &header_value, err
|
205 + | ),
|
206 + | )
|
207 + | })?;
|
208 + | builder = builder.header("initial-response-member", header_value);
|
209 + | }
|
210 + | }
|
211 + | Ok(builder)
|
212 + | }
|