1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_error_serialization_operation_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::ErrorSerializationOperationInput,
|
7 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection,
|
8 + | >
|
9 + | where
|
10 + | B: ::aws_smithy_legacy_http_server::body::HttpBody + Send,
|
11 + | B::Data: Send,
|
12 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::RequestRejection:
|
13 + | From<<B as ::aws_smithy_legacy_http_server::body::HttpBody>::Error>,
|
14 + | {
|
15 + | Ok({
|
16 + | #[allow(unused_mut)]
|
17 + | let mut input = crate::input::error_serialization_operation_input::Builder::default();
|
18 + | #[allow(unused_variables)]
|
19 + | let ::aws_smithy_runtime_api::http::RequestParts {
|
20 + | uri, headers, body, ..
|
21 + | } = ::aws_smithy_runtime_api::http::Request::try_from(request)?.into_parts();
|
22 + | let bytes = ::hyper::body::to_bytes(body).await?;
|
23 + | if !bytes.is_empty() {
|
24 + | ::aws_smithy_legacy_http_server::protocol::content_type_header_classifier_smithy(
|
25 + | &headers,
|
26 + | Some("application/cbor"),
|
27 + | )?;
|
28 + | input = crate::protocol_serde::shape_error_serialization_operation::de_error_serialization_operation(bytes.as_ref(), input)?;
|
29 + | }
|
30 + | input.build()?
|
31 + | })
|
32 + | }
|
33 + |
|
34 + | #[allow(clippy::unnecessary_wraps)]
|
35 + | pub fn ser_error_serialization_operation_http_response(
|
36 + | #[allow(unused_variables)] output: crate::output::ErrorSerializationOperationOutput,
|
37 + | ) -> std::result::Result<
|
38 + | ::aws_smithy_legacy_http_server::response::Response,
|
39 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
|
40 + | > {
|
41 + | Ok({
|
42 + | #[allow(unused_mut)]
|
43 + | let mut builder = ::http::Response::builder();
|
44 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
45 + | builder,
|
46 + | ::http::header::CONTENT_TYPE,
|
47 + | "application/cbor",
|
48 + | );
|
49 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
50 + | builder,
|
51 + | ::http::header::HeaderName::from_static("smithy-protocol"),
|
52 + | "rpc-v2-cbor",
|
53 + | );
|
54 + | let http_status: u16 = 200;
|
55 + | builder = builder.status(http_status);
|
56 + | let payload =
|
57 + | crate::protocol_serde::shape_error_serialization_operation_output::ser_error_serialization_operation_output_output_output(&output)?
|
58 + | ;
|
59 + | let content_length = payload.len();
|
60 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
61 + | builder,
|
62 + | ::http::header::CONTENT_LENGTH,
|
63 + | content_length,
|
64 + | );
|
65 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
66 + | builder.body(body)?
|
67 + | })
|
68 + | }
|
69 + |
|
70 + | #[allow(clippy::unnecessary_wraps)]
|
71 + | pub fn ser_error_serialization_operation_http_error(
|
72 + | error: &crate::error::ErrorSerializationOperationError,
|
73 + | ) -> std::result::Result<
|
74 + | ::aws_smithy_legacy_http_server::response::Response,
|
75 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
|
76 + | > {
|
77 + | Ok({
|
78 + | match error {
|
79 + | crate::error::ErrorSerializationOperationError::ValidationException(output) => {
|
80 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
81 + | #[allow(unused_mut)]
|
82 + | let mut builder = ::http::Response::builder();
|
83 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
84 + | builder,
|
85 + | ::http::header::CONTENT_TYPE,
|
86 + | "application/cbor",
|
87 + | );
|
88 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
89 + | builder,
|
90 + | ::http::header::HeaderName::from_static("smithy-protocol"),
|
91 + | "rpc-v2-cbor",
|
92 + | );
|
93 + | let content_length = payload.len();
|
94 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
95 + | builder,
|
96 + | ::http::header::CONTENT_LENGTH,
|
97 + | content_length,
|
98 + | );
|
99 + | builder
|
100 + | .status(400)
|
101 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
102 + | }
|
103 + | }
|
104 + | })
|
105 + | }
|
106 + |
|
107 + | pub(crate) fn de_error_serialization_operation(
|
108 + | value: &[u8],
|
109 + | mut builder: crate::input::error_serialization_operation_input::Builder,
|
110 + | ) -> ::std::result::Result<
|
111 + | crate::input::error_serialization_operation_input::Builder,
|
112 + | ::aws_smithy_cbor::decode::DeserializeError,
|
113 + | > {
|
114 + | #[allow(clippy::match_single_binding)]
|
115 + | fn pair(
|
116 + | mut builder: crate::input::error_serialization_operation_input::Builder,
|
117 + | decoder: &mut ::aws_smithy_cbor::Decoder,
|
118 + | ) -> ::std::result::Result<
|
119 + | crate::input::error_serialization_operation_input::Builder,
|
120 + | ::aws_smithy_cbor::decode::DeserializeError,
|
121 + | > {
|
122 + | builder = match decoder.str()?.as_ref() {
|
123 + | "blob" => {
|
124 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
125 + | Ok(builder.set_blob(Some(decoder.blob()?)))
|
126 + | })?
|
127 + | }
|
128 + | "boolean" => {
|
129 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
130 + | Ok(builder.set_boolean(Some(decoder.boolean()?)))
|
131 + | })?
|
132 + | }
|
133 + | "string" => {
|
134 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
135 + | Ok(builder.set_string(Some(decoder.string()?)))
|
136 + | })?
|
137 + | }
|
138 + | "byte" => {
|
139 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
140 + | Ok(builder.set_byte(Some(decoder.byte()?)))
|
141 + | })?
|
142 + | }
|
143 + | "short" => {
|
144 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
145 + | Ok(builder.set_short(Some(decoder.short()?)))
|
146 + | })?
|
147 + | }
|
148 + | "integer" => {
|
149 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
150 + | Ok(builder.set_integer(Some(decoder.integer()?)))
|
151 + | })?
|
152 + | }
|
153 + | "long" => {
|
154 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
155 + | Ok(builder.set_long(Some(decoder.long()?)))
|
156 + | })?
|
157 + | }
|
158 + | "float" => {
|
159 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
160 + | Ok(builder.set_float(Some(decoder.float()?)))
|
161 + | })?
|
162 + | }
|
163 + | "double" => {
|
164 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
165 + | Ok(builder.set_double(Some(decoder.double()?)))
|
166 + | })?
|
167 + | }
|
168 + | "timestamp" => {
|
169 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
170 + | Ok(builder.set_timestamp(Some(decoder.timestamp()?)))
|
171 + | })?
|
172 + | }
|
173 + | "enum" => {
|
174 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
175 + | Ok(builder.set_enum(Some(decoder.string()?)))
|
176 + | })?
|
177 + | }
|
178 + | "requiredBlob" => builder.set_required_blob(decoder.blob()?),
|
179 + | "requiredBoolean" => builder.set_required_boolean(decoder.boolean()?),
|
180 + | "requiredString" => builder.set_required_string(decoder.string()?),
|
181 + | "requiredByte" => builder.set_required_byte(decoder.byte()?),
|
182 + | "requiredShort" => builder.set_required_short(decoder.short()?),
|
183 + | "requiredInteger" => builder.set_required_integer(decoder.integer()?),
|
184 + | "requiredLong" => builder.set_required_long(decoder.long()?),
|
185 + | "requiredFloat" => builder.set_required_float(decoder.float()?),
|
186 + | "requiredDouble" => builder.set_required_double(decoder.double()?),
|
187 + | "requiredTimestamp" => builder.set_required_timestamp(decoder.timestamp()?),
|
188 + | "requiredEnum" => builder.set_required_enum(decoder.string()?),
|
189 + | _ => {
|
190 + | decoder.skip()?;
|
191 + | builder
|
192 + | }
|
193 + | };
|
194 + | Ok(builder)
|
195 + | }
|
196 + |
|
197 + | let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
|
198 + |
|
199 + | match decoder.map()? {
|
200 + | None => loop {
|
201 + | match decoder.datatype()? {
|
202 + | ::aws_smithy_cbor::data::Type::Break => {
|
203 + | decoder.skip()?;
|
204 + | break;
|
205 + | }
|
206 + | _ => {
|
207 + | builder = pair(builder, decoder)?;
|
208 + | }
|
209 + | };
|
210 + | },
|
211 + | Some(n) => {
|
212 + | for _ in 0..n {
|
213 + | builder = pair(builder, decoder)?;
|
214 + | }
|
215 + | }
|
216 + | };
|
217 + |
|
218 + | if decoder.position() != value.len() {
|
219 + | return Err(
|
220 + | ::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()),
|
221 + | );
|
222 + | }
|
223 + |
|
224 + | Ok(builder)
|
225 + | }
|