1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_greeting_with_errors_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::GreetingWithErrorsInput,
|
7 + | ::aws_smithy_legacy_http_server::protocol::aws_json::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::aws_json::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::greeting_with_errors_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/x-amz-json-1.0"),
|
27 + | )?;
|
28 + | input = crate::protocol_serde::shape_greeting_with_errors::de_greeting_with_errors(
|
29 + | bytes.as_ref(),
|
30 + | input,
|
31 + | )?;
|
32 + | }
|
33 + | input.build()
|
34 + | })
|
35 + | }
|
36 + |
|
37 + | #[allow(clippy::unnecessary_wraps)]
|
38 + | pub fn ser_greeting_with_errors_http_response(
|
39 + | #[allow(unused_variables)] output: crate::output::GreetingWithErrorsOutput,
|
40 + | ) -> std::result::Result<
|
41 + | ::aws_smithy_legacy_http_server::response::Response,
|
42 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
|
43 + | > {
|
44 + | Ok({
|
45 + | #[allow(unused_mut)]
|
46 + | let mut builder = ::http::Response::builder();
|
47 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
48 + | builder,
|
49 + | ::http::header::CONTENT_TYPE,
|
50 + | "application/x-amz-json-1.0",
|
51 + | );
|
52 + | let http_status: u16 = 200;
|
53 + | builder = builder.status(http_status);
|
54 + | let payload =
|
55 + | crate::protocol_serde::shape_greeting_with_errors_output::ser_greeting_with_errors_output_output_output(&output)?
|
56 + | ;
|
57 + | let content_length = payload.len();
|
58 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
59 + | builder,
|
60 + | ::http::header::CONTENT_LENGTH,
|
61 + | content_length,
|
62 + | );
|
63 + | let body = ::aws_smithy_legacy_http_server::body::to_boxed(payload);
|
64 + | builder.body(body)?
|
65 + | })
|
66 + | }
|
67 + |
|
68 + | #[allow(clippy::unnecessary_wraps)]
|
69 + | pub fn ser_greeting_with_errors_http_error(
|
70 + | error: &crate::error::GreetingWithErrorsError,
|
71 + | ) -> std::result::Result<
|
72 + | ::aws_smithy_legacy_http_server::response::Response,
|
73 + | ::aws_smithy_legacy_http_server::protocol::aws_json::rejection::ResponseRejection,
|
74 + | > {
|
75 + | Ok({
|
76 + | match error {
|
77 + | crate::error::GreetingWithErrorsError::InvalidGreeting(output) => {
|
78 + | let payload =
|
79 + | crate::protocol_serde::shape_invalid_greeting::ser_invalid_greeting_error(
|
80 + | output,
|
81 + | )?;
|
82 + | #[allow(unused_mut)]
|
83 + | let mut builder = ::http::Response::builder();
|
84 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
85 + | builder,
|
86 + | ::http::header::CONTENT_TYPE,
|
87 + | "application/x-amz-json-1.0",
|
88 + | );
|
89 + | let content_length = payload.len();
|
90 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
91 + | builder,
|
92 + | ::http::header::CONTENT_LENGTH,
|
93 + | content_length,
|
94 + | );
|
95 + | builder
|
96 + | .status(400)
|
97 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
98 + | }
|
99 + | crate::error::GreetingWithErrorsError::ComplexError(output) => {
|
100 + | let payload =
|
101 + | crate::protocol_serde::shape_complex_error::ser_complex_error_error(output)?;
|
102 + | #[allow(unused_mut)]
|
103 + | let mut builder = ::http::Response::builder();
|
104 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
105 + | builder,
|
106 + | ::http::header::CONTENT_TYPE,
|
107 + | "application/x-amz-json-1.0",
|
108 + | );
|
109 + | let content_length = payload.len();
|
110 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
111 + | builder,
|
112 + | ::http::header::CONTENT_LENGTH,
|
113 + | content_length,
|
114 + | );
|
115 + | builder
|
116 + | .status(400)
|
117 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
118 + | }
|
119 + | crate::error::GreetingWithErrorsError::FooError(output) => {
|
120 + | let payload = crate::protocol_serde::shape_foo_error::ser_foo_error_error(output)?;
|
121 + | #[allow(unused_mut)]
|
122 + | let mut builder = ::http::Response::builder();
|
123 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
124 + | builder,
|
125 + | ::http::header::CONTENT_TYPE,
|
126 + | "application/x-amz-json-1.0",
|
127 + | );
|
128 + | let content_length = payload.len();
|
129 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
130 + | builder,
|
131 + | ::http::header::CONTENT_LENGTH,
|
132 + | content_length,
|
133 + | );
|
134 + | builder
|
135 + | .status(500)
|
136 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
137 + | }
|
138 + | }
|
139 + | })
|
140 + | }
|
141 + |
|
142 + | pub(crate) fn de_greeting_with_errors(
|
143 + | value: &[u8],
|
144 + | mut builder: crate::input::greeting_with_errors_input::Builder,
|
145 + | ) -> ::std::result::Result<
|
146 + | crate::input::greeting_with_errors_input::Builder,
|
147 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
148 + | > {
|
149 + | let mut tokens_owned =
|
150 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
151 + | .peekable();
|
152 + | let tokens = &mut tokens_owned;
|
153 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
154 + | loop {
|
155 + | match tokens.next().transpose()? {
|
156 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
157 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
158 + | match key.to_unescaped()?.as_ref() {
|
159 + | "greeting" => {
|
160 + | builder = builder.set_greeting(
|
161 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(
|
162 + | tokens.next(),
|
163 + | )?
|
164 + | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
165 + | .transpose()?,
|
166 + | );
|
167 + | }
|
168 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
169 + | }
|
170 + | }
|
171 + | other => {
|
172 + | return Err(
|
173 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
174 + | "expected object key or end object, found: {other:?}"
|
175 + | )),
|
176 + | )
|
177 + | }
|
178 + | }
|
179 + | }
|
180 + | if tokens.next().is_some() {
|
181 + | return Err(
|
182 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
183 + | "found more JSON tokens after completing parsing",
|
184 + | ),
|
185 + | );
|
186 + | }
|
187 + | Ok(builder)
|
188 + | }
|