Skip to main content

aws_sdk_iot/protocol_serde/
shape_get_topic_rule_destination.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_topic_rule_destination_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::get_topic_rule_destination::GetTopicRuleDestinationOutput,
9    crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError,
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::get_topic_rule_destination::GetTopicRuleDestinationError::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 => {
19            return Err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled(
20                generic,
21            ))
22        }
23    };
24
25    let _error_message = generic.message().map(|msg| msg.to_owned());
26    Err(match error_code {
27        "InternalException" => crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::InternalException({
28            #[allow(unused_mut)]
29            let mut tmp = {
30                #[allow(unused_mut)]
31                let mut output = crate::types::error::builders::InternalExceptionBuilder::default();
32                output = crate::protocol_serde::shape_internal_exception::de_internal_exception_json_err(_response_body, output)
33                    .map_err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled)?;
34                let output = output.meta(generic);
35                output.build()
36            };
37            if tmp.message.is_none() {
38                tmp.message = _error_message;
39            }
40            tmp
41        }),
42        "InvalidRequestException" => crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::InvalidRequestException({
43            #[allow(unused_mut)]
44            let mut tmp = {
45                #[allow(unused_mut)]
46                let mut output = crate::types::error::builders::InvalidRequestExceptionBuilder::default();
47                output = crate::protocol_serde::shape_invalid_request_exception::de_invalid_request_exception_json_err(_response_body, output)
48                    .map_err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled)?;
49                let output = output.meta(generic);
50                output.build()
51            };
52            if tmp.message.is_none() {
53                tmp.message = _error_message;
54            }
55            tmp
56        }),
57        "ServiceUnavailableException" => crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::ServiceUnavailableException({
58            #[allow(unused_mut)]
59            let mut tmp = {
60                #[allow(unused_mut)]
61                let mut output = crate::types::error::builders::ServiceUnavailableExceptionBuilder::default();
62                output =
63                    crate::protocol_serde::shape_service_unavailable_exception::de_service_unavailable_exception_json_err(_response_body, output)
64                        .map_err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled)?;
65                let output = output.meta(generic);
66                output.build()
67            };
68            if tmp.message.is_none() {
69                tmp.message = _error_message;
70            }
71            tmp
72        }),
73        "UnauthorizedException" => crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::UnauthorizedException({
74            #[allow(unused_mut)]
75            let mut tmp = {
76                #[allow(unused_mut)]
77                let mut output = crate::types::error::builders::UnauthorizedExceptionBuilder::default();
78                output = crate::protocol_serde::shape_unauthorized_exception::de_unauthorized_exception_json_err(_response_body, output)
79                    .map_err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled)?;
80                let output = output.meta(generic);
81                output.build()
82            };
83            if tmp.message.is_none() {
84                tmp.message = _error_message;
85            }
86            tmp
87        }),
88        _ => crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::generic(generic),
89    })
90}
91
92#[allow(clippy::unnecessary_wraps)]
93pub fn de_get_topic_rule_destination_http_response(
94    _response_status: u16,
95    _response_headers: &::aws_smithy_runtime_api::http::Headers,
96    _response_body: &[u8],
97) -> std::result::Result<
98    crate::operation::get_topic_rule_destination::GetTopicRuleDestinationOutput,
99    crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError,
100> {
101    Ok({
102        #[allow(unused_mut)]
103        let mut output = crate::operation::get_topic_rule_destination::builders::GetTopicRuleDestinationOutputBuilder::default();
104        output = crate::protocol_serde::shape_get_topic_rule_destination::de_get_topic_rule_destination(_response_body, output)
105            .map_err(crate::operation::get_topic_rule_destination::GetTopicRuleDestinationError::unhandled)?;
106        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
107        output.build()
108    })
109}
110
111pub(crate) fn de_get_topic_rule_destination(
112    _value: &[u8],
113    mut builder: crate::operation::get_topic_rule_destination::builders::GetTopicRuleDestinationOutputBuilder,
114) -> ::std::result::Result<
115    crate::operation::get_topic_rule_destination::builders::GetTopicRuleDestinationOutputBuilder,
116    ::aws_smithy_json::deserialize::error::DeserializeError,
117> {
118    let mut tokens_owned = ::aws_smithy_json::deserialize::json_token_iter(crate::protocol_serde::or_empty_doc(_value)).peekable();
119    let tokens = &mut tokens_owned;
120    ::aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
121    loop {
122        match tokens.next().transpose()? {
123            Some(::aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
124            Some(::aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => match key.to_unescaped()?.as_ref() {
125                "topicRuleDestination" => {
126                    builder = builder.set_topic_rule_destination(crate::protocol_serde::shape_topic_rule_destination::de_topic_rule_destination(
127                        tokens, _value,
128                    )?);
129                }
130                _ => ::aws_smithy_json::deserialize::token::skip_value(tokens)?,
131            },
132            other => {
133                return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
134                    "expected object key or end object, found: {other:?}"
135                )))
136            }
137        }
138    }
139    if tokens.next().is_some() {
140        return Err(::aws_smithy_json::deserialize::error::DeserializeError::custom(
141            "found more JSON tokens after completing parsing",
142        ));
143    }
144    Ok(builder)
145}