1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_operation_with_defaults_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::OperationWithDefaultsInput,
|
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::operation_with_defaults_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 =
|
29 + | crate::protocol_serde::shape_operation_with_defaults::de_operation_with_defaults(
|
30 + | bytes.as_ref(),
|
31 + | input,
|
32 + | )?;
|
33 + | }
|
34 + | input.build()?
|
35 + | })
|
36 + | }
|
37 + |
|
38 + | #[allow(clippy::unnecessary_wraps)]
|
39 + | pub fn ser_operation_with_defaults_http_response(
|
40 + | #[allow(unused_variables)] output: crate::output::OperationWithDefaultsOutput,
|
41 + | ) -> std::result::Result<
|
42 + | ::aws_smithy_legacy_http_server::response::Response,
|
43 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
|
44 + | > {
|
45 + | Ok({
|
46 + | #[allow(unused_mut)]
|
47 + | let mut builder = ::http::Response::builder();
|
48 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
49 + | builder,
|
50 + | ::http::header::CONTENT_TYPE,
|
51 + | "application/cbor",
|
52 + | );
|
53 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
54 + | builder,
|
55 + | ::http::header::HeaderName::from_static("smithy-protocol"),
|
56 + | "rpc-v2-cbor",
|
57 + | );
|
58 + | let http_status: u16 = 200;
|
59 + | builder = builder.status(http_status);
|
60 + | let payload =
|
61 + | crate::protocol_serde::shape_operation_with_defaults_output::ser_operation_with_defaults_output_output_output(&output)?
|
62 + | ;
|
63 + | let content_length = payload.len();
|
64 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
65 + | builder,
|
66 + | ::http::header::CONTENT_LENGTH,
|
67 + | content_length,
|
68 + | );
|
69 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
70 + | builder.body(body)?
|
71 + | })
|
72 + | }
|
73 + |
|
74 + | #[allow(clippy::unnecessary_wraps)]
|
75 + | pub fn ser_operation_with_defaults_http_error(
|
76 + | error: &crate::error::OperationWithDefaultsError,
|
77 + | ) -> std::result::Result<
|
78 + | ::aws_smithy_legacy_http_server::response::Response,
|
79 + | ::aws_smithy_legacy_http_server::protocol::rpc_v2_cbor::rejection::ResponseRejection,
|
80 + | > {
|
81 + | Ok({
|
82 + | match error {
|
83 + | crate::error::OperationWithDefaultsError::ValidationException(output) => {
|
84 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
85 + | #[allow(unused_mut)]
|
86 + | let mut builder = ::http::Response::builder();
|
87 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
88 + | builder,
|
89 + | ::http::header::CONTENT_TYPE,
|
90 + | "application/cbor",
|
91 + | );
|
92 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
93 + | builder,
|
94 + | ::http::header::HeaderName::from_static("smithy-protocol"),
|
95 + | "rpc-v2-cbor",
|
96 + | );
|
97 + | let content_length = payload.len();
|
98 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
99 + | builder,
|
100 + | ::http::header::CONTENT_LENGTH,
|
101 + | content_length,
|
102 + | );
|
103 + | builder
|
104 + | .status(400)
|
105 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
106 + | }
|
107 + | }
|
108 + | })
|
109 + | }
|
110 + |
|
111 + | pub(crate) fn de_operation_with_defaults(
|
112 + | value: &[u8],
|
113 + | mut builder: crate::input::operation_with_defaults_input::Builder,
|
114 + | ) -> ::std::result::Result<
|
115 + | crate::input::operation_with_defaults_input::Builder,
|
116 + | ::aws_smithy_cbor::decode::DeserializeError,
|
117 + | > {
|
118 + | #[allow(clippy::match_single_binding)]
|
119 + | fn pair(
|
120 + | mut builder: crate::input::operation_with_defaults_input::Builder,
|
121 + | decoder: &mut ::aws_smithy_cbor::Decoder,
|
122 + | ) -> ::std::result::Result<
|
123 + | crate::input::operation_with_defaults_input::Builder,
|
124 + | ::aws_smithy_cbor::decode::DeserializeError,
|
125 + | > {
|
126 + | builder = match decoder.str()?.as_ref() {
|
127 + | "defaults" => {
|
128 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
129 + | Ok(builder.set_defaults(Some(
|
130 + | crate::protocol_serde::shape_defaults::de_defaults(decoder)?,
|
131 + | )))
|
132 + | })?
|
133 + | }
|
134 + | "clientOptionalDefaults" => {
|
135 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
136 + | Ok(builder.set_client_optional_defaults(
|
137 + | Some(
|
138 + | crate::protocol_serde::shape_client_optional_defaults::de_client_optional_defaults(decoder)?
|
139 + | )
|
140 + | ))
|
141 + | })?
|
142 + | }
|
143 + | "topLevelDefault" => {
|
144 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
145 + | Ok(builder.set_top_level_default(decoder.string()?))
|
146 + | })?
|
147 + | }
|
148 + | "otherTopLevelDefault" => {
|
149 + | ::aws_smithy_cbor::decode::set_optional(builder, decoder, |builder, decoder| {
|
150 + | Ok(builder.set_other_top_level_default(decoder.integer()?))
|
151 + | })?
|
152 + | }
|
153 + | _ => {
|
154 + | decoder.skip()?;
|
155 + | builder
|
156 + | }
|
157 + | };
|
158 + | Ok(builder)
|
159 + | }
|
160 + |
|
161 + | let decoder = &mut ::aws_smithy_cbor::Decoder::new(value);
|
162 + |
|
163 + | match decoder.map()? {
|
164 + | None => loop {
|
165 + | match decoder.datatype()? {
|
166 + | ::aws_smithy_cbor::data::Type::Break => {
|
167 + | decoder.skip()?;
|
168 + | break;
|
169 + | }
|
170 + | _ => {
|
171 + | builder = pair(builder, decoder)?;
|
172 + | }
|
173 + | };
|
174 + | },
|
175 + | Some(n) => {
|
176 + | for _ in 0..n {
|
177 + | builder = pair(builder, decoder)?;
|
178 + | }
|
179 + | }
|
180 + | };
|
181 + |
|
182 + | if decoder.position() != value.len() {
|
183 + | return Err(
|
184 + | ::aws_smithy_cbor::decode::DeserializeError::expected_end_of_stream(decoder.position()),
|
185 + | );
|
186 + | }
|
187 + |
|
188 + | Ok(builder)
|
189 + | }
|