1 + | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 + | #[allow(clippy::unnecessary_wraps)]
|
3 + | pub async fn de_content_type_parameters_http_request<B>(
|
4 + | #[allow(unused_variables)] request: ::http::Request<B>,
|
5 + | ) -> std::result::Result<
|
6 + | crate::input::ContentTypeParametersInput,
|
7 + | ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection,
|
8 + | >
|
9 + | where
|
10 + | B: ::aws_smithy_http_server::body::HttpBody + Send,
|
11 + | B::Data: Send,
|
12 + | ::aws_smithy_http_server::protocol::aws_json::rejection::RequestRejection:
|
13 + | From<<B as ::aws_smithy_http_server::body::HttpBody>::Error>,
|
14 + | {
|
15 + | Ok({
|
16 + | #[allow(unused_mut)]
|
17 + | let mut input = crate::input::content_type_parameters_input_internal::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_http_server::protocol::content_type_header_classifier_smithy(
|
25 + | &headers,
|
26 + | Some("application/x-amz-json-1.0"),
|
27 + | )?;
|
28 + | input =
|
29 + | crate::protocol_serde::shape_content_type_parameters::de_content_type_parameters(
|
30 + | bytes.as_ref(),
|
31 + | input,
|
32 + | )?;
|
33 + | }
|
34 + | input.build()
|
35 + | })
|
36 + | }
|
37 + |
|
38 + | #[allow(clippy::unnecessary_wraps)]
|
39 + | pub fn ser_content_type_parameters_http_response(
|
40 + | #[allow(unused_variables)] output: crate::output::ContentTypeParametersOutput,
|
41 + | ) -> std::result::Result<
|
42 + | ::aws_smithy_http_server::response::Response,
|
43 + | ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
|
44 + | > {
|
45 + | Ok({
|
46 + | #[allow(unused_mut)]
|
47 + | let mut builder = ::http::Response::builder();
|
48 + | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
49 + | builder,
|
50 + | ::http::header::CONTENT_TYPE,
|
51 + | "application/x-amz-json-1.0",
|
52 + | );
|
53 + | let http_status: u16 = 200;
|
54 + | builder = builder.status(http_status);
|
55 + | let payload =
|
56 + | crate::protocol_serde::shape_content_type_parameters_output::ser_content_type_parameters_output_output_output(&output)?
|
57 + | ;
|
58 + | let content_length = payload.len();
|
59 + | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
60 + | builder,
|
61 + | ::http::header::CONTENT_LENGTH,
|
62 + | content_length,
|
63 + | );
|
64 + | let body = ::aws_smithy_http_server::body::to_boxed(payload);
|
65 + | builder.body(body)?
|
66 + | })
|
67 + | }
|
68 + |
|
69 + | #[allow(clippy::unnecessary_wraps)]
|
70 + | pub fn ser_content_type_parameters_http_error(
|
71 + | error: &crate::error::ContentTypeParametersError,
|
72 + | ) -> std::result::Result<
|
73 + | ::aws_smithy_http_server::response::Response,
|
74 + | ::aws_smithy_http_server::protocol::aws_json::rejection::ResponseRejection,
|
75 + | > {
|
76 + | Ok({
|
77 + | match error {
|
78 + | crate::error::ContentTypeParametersError::InternalServerError(output) => {
|
79 + | let payload = crate::protocol_serde::shape_internal_server_error::ser_internal_server_error_error(output)?;
|
80 + | #[allow(unused_mut)]
|
81 + | let mut builder = ::http::Response::builder();
|
82 + | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
83 + | builder,
|
84 + | ::http::header::CONTENT_TYPE,
|
85 + | "application/x-amz-json-1.0",
|
86 + | );
|
87 + | let content_length = payload.len();
|
88 + | builder = ::aws_smithy_http::header::set_response_header_if_absent(
|
89 + | builder,
|
90 + | ::http::header::CONTENT_LENGTH,
|
91 + | content_length,
|
92 + | );
|
93 + | builder
|
94 + | .status(500)
|
95 + | .body(::aws_smithy_http_server::body::to_boxed(payload))?
|
96 + | }
|
97 + | }
|
98 + | })
|
99 + | }
|
100 + |
|
101 + | pub(crate) fn de_content_type_parameters(
|
102 + | value: &[u8],
|
103 + | mut builder: crate::input::content_type_parameters_input_internal::Builder,
|
104 + | ) -> Result<
|
105 + | crate::input::content_type_parameters_input_internal::Builder,
|
106 + | ::aws_smithy_json::deserialize::error::DeserializeError,
|
107 + | > {
|
108 + | let mut tokens_owned =
|
109 + | ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value))
|
110 + | .peekable();
|
111 + | let tokens = &mut tokens_owned;
|
112 + | ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
|
113 + | loop {
|
114 + | match tokens.next().transpose()? {
|
115 + | Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
|
116 + | Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
|
117 + | match key.to_unescaped()?.as_ref() {
|
118 + | "value" => {
|
119 + | builder = builder.set_value(
|
120 + | ::aws_smithy_json::deserialize::token::expect_number_or_null(
|
121 + | tokens.next(),
|
122 + | )?
|
123 + | .map(i32::try_from)
|
124 + | .transpose()?,
|
125 + | );
|
126 + | }
|
127 + | _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
|
128 + | }
|
129 + | }
|
130 + | other => {
|
131 + | return Err(
|
132 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
|
133 + | "expected object key or end object, found: {:?}",
|
134 + | other
|
135 + | )),
|
136 + | )
|
137 + | }
|
138 + | }
|
139 + | }
|
140 + | if tokens.next().is_some() {
|
141 + | return Err(
|
142 + | ::aws_smithy_json::deserialize::error::DeserializeError::custom(
|
143 + | "found more JSON tokens after completing parsing",
|
144 + | ),
|
145 + | );
|
146 + | }
|
147 + | Ok(builder)
|
148 + | }
|