aws_sdk_swf/protocol_serde/
shape_count_closed_workflow_executions.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_count_closed_workflow_executions_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::count_closed_workflow_executions::CountClosedWorkflowExecutionsOutput,
9    crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError,
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::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    let error_code = match generic.code() {
17        Some(code) => code,
18        None => return Err(crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::unhandled(generic)),
19    };
20
21    let _error_message = generic.message().map(|msg| msg.to_owned());
22    Err(match error_code {
23        "OperationNotPermittedFault" => {
24            crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::OperationNotPermittedFault({
25                #[allow(unused_mut)]
26                let mut tmp = {
27                    #[allow(unused_mut)]
28                    let mut output = crate::types::error::builders::OperationNotPermittedFaultBuilder::default();
29                    output =
30                        crate::protocol_serde::shape_operation_not_permitted_fault::de_operation_not_permitted_fault_json_err(_response_body, output)
31                            .map_err(crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::unhandled)?;
32                    let output = output.meta(generic);
33                    output.build()
34                };
35                if tmp.message.is_none() {
36                    tmp.message = _error_message;
37                }
38                tmp
39            })
40        }
41        "UnknownResourceFault" => crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::UnknownResourceFault({
42            #[allow(unused_mut)]
43            let mut tmp = {
44                #[allow(unused_mut)]
45                let mut output = crate::types::error::builders::UnknownResourceFaultBuilder::default();
46                output = crate::protocol_serde::shape_unknown_resource_fault::de_unknown_resource_fault_json_err(_response_body, output)
47                    .map_err(crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::unhandled)?;
48                let output = output.meta(generic);
49                output.build()
50            };
51            if tmp.message.is_none() {
52                tmp.message = _error_message;
53            }
54            tmp
55        }),
56        _ => crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::generic(generic),
57    })
58}
59
60#[allow(clippy::unnecessary_wraps)]
61pub fn de_count_closed_workflow_executions_http_response(
62    _response_status: u16,
63    _response_headers: &::aws_smithy_runtime_api::http::Headers,
64    _response_body: &[u8],
65) -> std::result::Result<
66    crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsOutput,
67    crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError,
68> {
69    Ok({
70        #[allow(unused_mut)]
71        let mut output = crate::operation::count_closed_workflow_executions::builders::CountClosedWorkflowExecutionsOutputBuilder::default();
72        output = crate::protocol_serde::shape_count_closed_workflow_executions::de_count_closed_workflow_executions(_response_body, output)
73            .map_err(crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsError::unhandled)?;
74        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
75        crate::serde_util::count_closed_workflow_executions_output_output_correct_errors(output).build()
76    })
77}
78
79pub fn ser_count_closed_workflow_executions_input(
80    input: &crate::operation::count_closed_workflow_executions::CountClosedWorkflowExecutionsInput,
81) -> ::std::result::Result<::aws_smithy_types::body::SdkBody, ::aws_smithy_types::error::operation::SerializationError> {
82    let mut out = String::new();
83    let mut object = ::aws_smithy_json::serialize::JsonObjectWriter::new(&mut out);
84    crate::protocol_serde::shape_count_closed_workflow_executions_input::ser_count_closed_workflow_executions_input_input(&mut object, input)?;
85    object.finish();
86    Ok(::aws_smithy_types::body::SdkBody::from(out))
87}
88
89pub(crate) fn de_count_closed_workflow_executions(
90    value: &[u8],
91    mut builder: crate::operation::count_closed_workflow_executions::builders::CountClosedWorkflowExecutionsOutputBuilder,
92) -> ::std::result::Result<
93    crate::operation::count_closed_workflow_executions::builders::CountClosedWorkflowExecutionsOutputBuilder,
94    ::aws_smithy_json::deserialize::error::DeserializeError,
95> {
96    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(value)).peekable();
97    let tokens = &mut tokens_owned;
98    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
99    loop {
100        match tokens.next().transpose()? {
101            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
102            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
103                "count" => {
104                    builder = builder.set_count(
105                        ::aws_smithy_json::deserialize::token::expect_number_or_null(tokens.next())?
106                            .map(i32::try_from)
107                            .transpose()?,
108                    );
109                }
110                "truncated" => {
111                    builder = builder.set_truncated(::aws_smithy_json::deserialize::token::expect_bool_or_null(tokens.next())?);
112                }
113                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
114            },
115            other => {
116                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
117                    "expected object key or end object, found: {:?}",
118                    other
119                )))
120            }
121        }
122    }
123    if tokens.next().is_some() {
124        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
125            "found more JSON tokens after completing parsing",
126        ));
127    }
128    Ok(builder)
129}