aws_sdk_sts/protocol_serde/
shape_get_caller_identity.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_get_caller_identity_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_caller_identity::GetCallerIdentityOutput, crate::operation::get_caller_identity::GetCallerIdentityError>
8{
9    #[allow(unused_mut)]
10    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
11        .map_err(crate::operation::get_caller_identity::GetCallerIdentityError::unhandled)?;
12    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
13    let generic = generic_builder.build();
14    Err(crate::operation::get_caller_identity::GetCallerIdentityError::generic(generic))
15}
16
17#[allow(clippy::unnecessary_wraps)]
18pub fn de_get_caller_identity_http_response(
19    _response_status: u16,
20    _response_headers: &::aws_smithy_runtime_api::http::Headers,
21    _response_body: &[u8],
22) -> std::result::Result<crate::operation::get_caller_identity::GetCallerIdentityOutput, crate::operation::get_caller_identity::GetCallerIdentityError>
23{
24    Ok({
25        #[allow(unused_mut)]
26        let mut output = crate::operation::get_caller_identity::builders::GetCallerIdentityOutputBuilder::default();
27        output = crate::protocol_serde::shape_get_caller_identity::de_get_caller_identity(_response_body, output)
28            .map_err(crate::operation::get_caller_identity::GetCallerIdentityError::unhandled)?;
29        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
30        output.build()
31    })
32}
33
34#[allow(unused_mut)]
35pub fn de_get_caller_identity(
36    inp: &[u8],
37    mut builder: crate::operation::get_caller_identity::builders::GetCallerIdentityOutputBuilder,
38) -> std::result::Result<crate::operation::get_caller_identity::builders::GetCallerIdentityOutputBuilder, ::aws_smithy_xml::decode::XmlDecodeError> {
39    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
40
41    #[allow(unused_mut)]
42    let mut decoder = doc.root_element()?;
43    #[allow(unused_variables)]
44    let start_el = decoder.start_el();
45    if !(start_el.matches("GetCallerIdentityResponse")) {
46        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
47            "invalid root, expected GetCallerIdentityResponse got {:?}",
48            start_el
49        )));
50    }
51    if let Some(mut result_tag) = decoder.next_tag() {
52        let start_el = result_tag.start_el();
53        if !(start_el.matches("GetCallerIdentityResult")) {
54            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
55                "invalid result, expected GetCallerIdentityResult got {:?}",
56                start_el
57            )));
58        }
59        while let Some(mut tag) = result_tag.next_tag() {
60            match tag.start_el() {
61            s if s.matches("UserId") /* UserId com.amazonaws.sts.synthetic#GetCallerIdentityOutput$UserId */ =>  {
62                let var_1 =
63                    Some(
64                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
65                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
66                            .into()
67                        )
68                        ?
69                    )
70                ;
71                builder = builder.set_user_id(var_1);
72            }
73            ,
74            s if s.matches("Account") /* Account com.amazonaws.sts.synthetic#GetCallerIdentityOutput$Account */ =>  {
75                let var_2 =
76                    Some(
77                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
78                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
79                            .into()
80                        )
81                        ?
82                    )
83                ;
84                builder = builder.set_account(var_2);
85            }
86            ,
87            s if s.matches("Arn") /* Arn com.amazonaws.sts.synthetic#GetCallerIdentityOutput$Arn */ =>  {
88                let var_3 =
89                    Some(
90                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
91                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
92                            .into()
93                        )
94                        ?
95                    )
96                ;
97                builder = builder.set_arn(var_3);
98            }
99            ,
100            _ => {}
101        }
102        }
103    } else {
104        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected GetCallerIdentityResult tag"));
105    };
106    Ok(builder)
107}