1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_escaped_string_values_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::EscapedStringValuesInput,
|
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::Data: Send,
|
12 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::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::escaped_string_values_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/json"),
|
27 + | )?;
|
28 + | input = crate::protocol_serde::shape_escaped_string_values::de_escaped_string_values(
|
29 + | bytes.as_ref(),
|
30 + | input,
|
31 + | )?;
|
32 + | }
|
33 + | input.build()?
|
34 + | })
|
35 + | }
|
36 + |
|
37 + | #[allow(clippy::unnecessary_wraps)]
|
38 + | pub fn ser_escaped_string_values_http_response(
|
39 + | #[allow(unused_variables)] output: crate::output::EscapedStringValuesOutput,
|
40 + | ) -> std::result::Result<
|
41 + | ::aws_smithy_legacy_http_server::response::Response,
|
42 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::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/json",
|
51 + | );
|
52 + | let http_status: u16 = 200;
|
53 + | builder = builder.status(http_status);
|
54 + | let payload =
|
55 + | crate::protocol_serde::shape_escaped_string_values_output::ser_escaped_string_values_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_escaped_string_values_http_error(
|
70 + | error: &crate::error::EscapedStringValuesError,
|
71 + | ) -> std::result::Result<
|
72 + | ::aws_smithy_legacy_http_server::response::Response,
|
73 + | ::aws_smithy_legacy_http_server::protocol::rest_json_1::rejection::ResponseRejection,
|
74 + | > {
|
75 + | Ok({
|
76 + | match error {
|
77 + | crate::error::EscapedStringValuesError::ValidationException(output) => {
|
78 + | let payload = crate::protocol_serde::shape_validation_exception::ser_validation_exception_error(output)?;
|
79 + | #[allow(unused_mut)]
|
80 + | let mut builder = ::http::Response::builder();
|
81 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
82 + | builder,
|
83 + | ::http::header::CONTENT_TYPE,
|
84 + | "application/json",
|
85 + | );
|
86 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
87 + | builder,
|
88 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
89 + | "ValidationException",
|
90 + | );
|
91 + | let content_length = payload.len();
|
92 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
93 + | builder,
|
94 + | ::http::header::CONTENT_LENGTH,
|
95 + | content_length,
|
96 + | );
|
97 + | builder
|
98 + | .status(400)
|
99 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
100 + | }
|
101 + | crate::error::EscapedStringValuesError::ExtraError(output) => {
|
102 + | let payload =
|
103 + | crate::protocol_serde::shape_extra_error::ser_extra_error_error(output)?;
|
104 + | #[allow(unused_mut)]
|
105 + | let mut builder = ::http::Response::builder();
|
106 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
107 + | builder,
|
108 + | ::http::header::CONTENT_TYPE,
|
109 + | "application/json",
|
110 + | );
|
111 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
112 + | builder,
|
113 + | ::http::header::HeaderName::from_static("x-amzn-errortype"),
|
114 + | "ExtraError",
|
115 + | );
|
116 + | let content_length = payload.len();
|
117 + | builder = ::aws_smithy_legacy_http::header::set_response_header_if_absent(
|
118 + | builder,
|
119 + | ::http::header::CONTENT_LENGTH,
|
120 + | content_length,
|
121 + | );
|
122 + | builder
|
123 + | .status(500)
|
124 + | .body(::aws_smithy_legacy_http_server::body::to_boxed(payload))?
|
125 + | }
|
126 + | }
|
127 + | })
|
128 + | }
|
129 + |
|
130 + | pub(crate) fn de_escaped_string_values(
|
131 + | value: &[u8],
|
132 + | mut builder: crate::input::escaped_string_values_input::Builder,
|
133 + | ) -> ::std::result::Result<
|
134 + | crate::input::escaped_string_values_input::Builder,
|
135 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
136 + | > {
|
137 + | let mut tokens_owned =
|
138 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
139 + | .peekable();
|
140 + | let tokens = &mut tokens_owned;
|
141 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
142 + | loop {
|
143 + | match tokens.next().transpose()? {
|
144 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
145 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
146 + | match key.to_unescaped()?.as_ref() {
|
147 + | "enum" => {
|
148 + | builder = builder.set_enum(
|
149 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(
|
150 + | tokens.next(),
|
151 + | )?
|
152 + | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
153 + | .transpose()?,
|
154 + | );
|
155 + | }
|
156 + | "also\"has\"quotes" => {
|
157 + | builder = builder.set_some_string(
|
158 + | ::aws_smithy_json::deserialize::token::expect_string_or_null(
|
159 + | tokens.next(),
|
160 + | )?
|
161 + | .map(|s| s.to_unescaped().map(|u| u.into_owned()))
|
162 + | .transpose()?,
|
163 + | );
|
164 + | }
|
165 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
166 + | }
|
167 + | }
|
168 + | other => {
|
169 + | return Err(
|
170 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
171 + | "expected object key or end object, found: {other:?}"
|
172 + | )),
|
173 + | )
|
174 + | }
|
175 + | }
|
176 + | }
|
177 + | if tokens.next().is_some() {
|
178 + | return Err(
|
179 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
180 + | "found more JSON tokens after completing parsing",
|
181 + | ),
|
182 + | );
|
183 + | }
|
184 + | Ok(builder)
|
185 + | }
|