aws_sdk_ec2/protocol_serde/
shape_attach_network_interface.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_attach_network_interface_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::attach_network_interface::AttachNetworkInterfaceOutput,
9    crate::operation::attach_network_interface::AttachNetworkInterfaceError,
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::attach_network_interface::AttachNetworkInterfaceError::unhandled)?;
14    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
15    let generic = generic_builder.build();
16    Err(crate::operation::attach_network_interface::AttachNetworkInterfaceError::generic(generic))
17}
18
19#[allow(clippy::unnecessary_wraps)]
20pub fn de_attach_network_interface_http_response(
21    _response_status: u16,
22    _response_headers: &::aws_smithy_runtime_api::http::Headers,
23    _response_body: &[u8],
24) -> std::result::Result<
25    crate::operation::attach_network_interface::AttachNetworkInterfaceOutput,
26    crate::operation::attach_network_interface::AttachNetworkInterfaceError,
27> {
28    Ok({
29        #[allow(unused_mut)]
30        let mut output = crate::operation::attach_network_interface::builders::AttachNetworkInterfaceOutputBuilder::default();
31        output = crate::protocol_serde::shape_attach_network_interface::de_attach_network_interface(_response_body, output)
32            .map_err(crate::operation::attach_network_interface::AttachNetworkInterfaceError::unhandled)?;
33        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
34        output.build()
35    })
36}
37
38#[allow(unused_mut)]
39pub fn de_attach_network_interface(
40    inp: &[u8],
41    mut builder: crate::operation::attach_network_interface::builders::AttachNetworkInterfaceOutputBuilder,
42) -> std::result::Result<
43    crate::operation::attach_network_interface::builders::AttachNetworkInterfaceOutputBuilder,
44    ::aws_smithy_xml::decode::XmlDecodeError,
45> {
46    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;
47
48    #[allow(unused_mut)]
49    let mut decoder = doc.root_element()?;
50    #[allow(unused_variables)]
51    let start_el = decoder.start_el();
52    if !(start_el.matches("AttachNetworkInterfaceResponse")) {
53        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
54            "invalid root, expected AttachNetworkInterfaceResponse got {:?}",
55            start_el
56        )));
57    }
58    while let Some(mut tag) = decoder.next_tag() {
59        match tag.start_el() {
60            s if s.matches("attachmentId") /* AttachmentId com.amazonaws.ec2.synthetic#AttachNetworkInterfaceOutput$AttachmentId */ =>  {
61                let var_1 =
62                    Some(
63                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
64                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
65                            .into()
66                        )
67                        ?
68                    )
69                ;
70                builder = builder.set_attachment_id(var_1);
71            }
72            ,
73            s if s.matches("networkCardIndex") /* NetworkCardIndex com.amazonaws.ec2.synthetic#AttachNetworkInterfaceOutput$NetworkCardIndex */ =>  {
74                let var_2 =
75                    Some(
76                         {
77                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
78                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
79                            )
80                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
81                        }
82                        ?
83                    )
84                ;
85                builder = builder.set_network_card_index(var_2);
86            }
87            ,
88            _ => {}
89        }
90    }
91    Ok(builder)
92}