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 {start_el:?}"
48        )));
49    }
50    if let Some(mut result_tag) = decoder.next_tag() {
51        let start_el = result_tag.start_el();
52        if !(start_el.matches("GetCallerIdentityResult")) {
53            return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
54                "invalid result, expected GetCallerIdentityResult got {start_el:?}"
55            )));
56        }
57        while let Some(mut tag) = result_tag.next_tag() {
58            match tag.start_el() {
59            s if s.matches("UserId") /* UserId com.amazonaws.sts.synthetic#GetCallerIdentityOutput$UserId */ =>  {
60                let var_1 =
61                    Some(
62                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
63                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
64                            .into()
65                        )
66                        ?
67                    )
68                ;
69                builder = builder.set_user_id(var_1);
70            }
71            ,
72            s if s.matches("Account") /* Account com.amazonaws.sts.synthetic#GetCallerIdentityOutput$Account */ =>  {
73                let var_2 =
74                    Some(
75                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
76                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
77                            .into()
78                        )
79                        ?
80                    )
81                ;
82                builder = builder.set_account(var_2);
83            }
84            ,
85            s if s.matches("Arn") /* Arn com.amazonaws.sts.synthetic#GetCallerIdentityOutput$Arn */ =>  {
86                let var_3 =
87                    Some(
88                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
89                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
90                            .into()
91                        )
92                        ?
93                    )
94                ;
95                builder = builder.set_arn(var_3);
96            }
97            ,
98            _ => {}
99        }
100        }
101    } else {
102        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("expected GetCallerIdentityResult tag"));
103    };
104    Ok(builder)
105}