aws_sdk_cloudfront/protocol_serde/
shape_get_function.rs1#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_function_http_error(
4 _response_status: u16,
5 _response_headers: &::aws_smithy_runtime_api::http::Headers,
6 _response_body: &[u8],
7) -> std::result::Result<crate::operation::get_function::GetFunctionOutput, crate::operation::get_function::GetFunctionError> {
8 #[allow(unused_mut)]
9 let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
10 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
11 generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
12 let generic = generic_builder.build();
13 let error_code = match generic.code() {
14 Some(code) => code,
15 None => return Err(crate::operation::get_function::GetFunctionError::unhandled(generic)),
16 };
17
18 let _error_message = generic.message().map(|msg| msg.to_owned());
19 Err(match error_code {
20 "NoSuchFunctionExists" => crate::operation::get_function::GetFunctionError::NoSuchFunctionExists({
21 #[allow(unused_mut)]
22 let mut tmp = {
23 #[allow(unused_mut)]
24 let mut output = crate::types::error::builders::NoSuchFunctionExistsBuilder::default();
25 output = crate::protocol_serde::shape_no_such_function_exists::de_no_such_function_exists_xml_err(_response_body, output)
26 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
27 let output = output.meta(generic);
28 output.build()
29 };
30 if tmp.message.is_none() {
31 tmp.message = _error_message;
32 }
33 tmp
34 }),
35 "UnsupportedOperation" => crate::operation::get_function::GetFunctionError::UnsupportedOperation({
36 #[allow(unused_mut)]
37 let mut tmp = {
38 #[allow(unused_mut)]
39 let mut output = crate::types::error::builders::UnsupportedOperationBuilder::default();
40 output = crate::protocol_serde::shape_unsupported_operation::de_unsupported_operation_xml_err(_response_body, output)
41 .map_err(crate::operation::get_function::GetFunctionError::unhandled)?;
42 let output = output.meta(generic);
43 output.build()
44 };
45 if tmp.message.is_none() {
46 tmp.message = _error_message;
47 }
48 tmp
49 }),
50 _ => crate::operation::get_function::GetFunctionError::generic(generic),
51 })
52}
53
54#[allow(clippy::unnecessary_wraps)]
55pub fn de_get_function_http_response(
56 _response_status: u16,
57 _response_headers: &::aws_smithy_runtime_api::http::Headers,
58 _response_body: &[u8],
59) -> std::result::Result<crate::operation::get_function::GetFunctionOutput, crate::operation::get_function::GetFunctionError> {
60 Ok({
61 #[allow(unused_mut)]
62 let mut output = crate::operation::get_function::builders::GetFunctionOutputBuilder::default();
63 output = output.set_content_type(
64 crate::protocol_serde::shape_get_function_output::de_content_type_header(_response_headers)
65 .map_err(|_| crate::operation::get_function::GetFunctionError::unhandled("Failed to parse ContentType from header `Content-Type"))?,
66 );
67 output = output.set_e_tag(
68 crate::protocol_serde::shape_get_function_output::de_e_tag_header(_response_headers)
69 .map_err(|_| crate::operation::get_function::GetFunctionError::unhandled("Failed to parse ETag from header `ETag"))?,
70 );
71 output = output.set_function_code(crate::protocol_serde::shape_get_function_output::de_function_code_payload(
72 _response_body,
73 )?);
74 output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
75 output.build()
76 })
77}