1 - | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
|
2 - | #[allow(clippy::unnecessary_wraps)]
|
3 - | pub fn de_http_payload_traits2_http_error(
|
4 - | _response_status: u16,
|
5 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
6 - | _response_body: &[u8],
|
7 - | ) -> std::result::Result<
|
8 - | crate::operation::http_payload_traits2::HttpPayloadTraits2Output,
|
9 - | crate::operation::http_payload_traits2::HttpPayloadTraits2Error,
|
10 - | > {
|
11 - | #[allow(unused_mut)]
|
12 - | let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
|
13 - | .map_err(crate::operation::http_payload_traits2::HttpPayloadTraits2Error::unhandled)?;
|
14 - | let generic = generic_builder.build();
|
15 - | let error_code = match generic.code() {
|
16 - | Some(code) => code,
|
17 - | None => return Err(crate::operation::http_payload_traits2::HttpPayloadTraits2Error::unhandled(generic)),
|
18 - | };
|
19 - |
|
20 - | let _error_message = generic.message().map(|msg| msg.to_owned());
|
21 - | Err(match error_code {
|
22 - | "ExtraError" => crate::operation::http_payload_traits2::HttpPayloadTraits2Error::ExtraError({
|
23 - | #[allow(unused_mut)]
|
24 - | let mut tmp = {
|
25 - | #[allow(unused_mut)]
|
26 - | let mut output = crate::types::error::builders::ExtraErrorBuilder::default();
|
27 - | output = crate::protocol_serde::shape_extra_error::de_extra_error_json_err(_response_body, output)
|
28 - | .map_err(crate::operation::http_payload_traits2::HttpPayloadTraits2Error::unhandled)?;
|
29 - | let output = output.meta(generic);
|
30 - | output.build()
|
31 - | };
|
32 - | if tmp.message.is_none() {
|
33 - | tmp.message = _error_message;
|
34 - | }
|
35 - | tmp
|
36 - | }),
|
37 - | _ => crate::operation::http_payload_traits2::HttpPayloadTraits2Error::generic(generic),
|
38 - | })
|
39 - | }
|
40 - |
|
41 - | #[allow(clippy::unnecessary_wraps)]
|
42 - | pub fn de_http_payload_traits2_http_response(
|
43 - | _response_status: u16,
|
44 - | _response_headers: &::aws_smithy_runtime_api::http::Headers,
|
45 - | _response_body: &[u8],
|
46 - | ) -> std::result::Result<
|
47 - | crate::operation::http_payload_traits2::HttpPayloadTraits2Output,
|
48 - | crate::operation::http_payload_traits2::HttpPayloadTraits2Error,
|
49 - | > {
|
50 - | Ok({
|
51 - | #[allow(unused_mut)]
|
52 - | let mut output = crate::operation::http_payload_traits2::builders::HttpPayloadTraits2OutputBuilder::default();
|
53 - | output = output.set_blob(crate::protocol_serde::shape_http_payload_traits2_output::de_blob_payload(_response_body)?);
|
54 - | output = output.set_foo(
|
55 - | crate::protocol_serde::shape_http_payload_traits2_output::de_foo_header(_response_headers)
|
56 - | .map_err(|_| crate::operation::http_payload_traits2::HttpPayloadTraits2Error::unhandled("Failed to parse foo from header `X-Foo"))?,
|
57 - | );
|
58 - | output.build()
|
59 - | })
|
60 - | }
|
61 - |
|
62 - | pub fn ser_http_payload_traits2_headers(
|
63 - | input: &crate::operation::http_payload_traits2::HttpPayloadTraits2Input,
|
64 - | mut builder: ::http::request::Builder,
|
65 - | ) -> std::result::Result<::http::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
|
66 - | if let ::std::option::Option::Some(inner_1) = &input.foo {
|
67 - | let formatted_2 = inner_1.as_str();
|
68 - | if !formatted_2.is_empty() {
|
69 - | let header_value = formatted_2;
|
70 - | let header_value: ::http::HeaderValue = header_value.parse().map_err(|err| {
|
71 - | ::aws_smithy_types::error::operation::BuildError::invalid_field(
|
72 - | "foo",
|
73 - | format!("`{}` cannot be used as a header value: {}", &header_value, err),
|
74 - | )
|
75 - | })?;
|
76 - | builder = builder.header("X-Foo", header_value);
|
77 - | }
|
78 - | }
|
79 - | Ok(builder)
|
80 - | }
|