aws_sdk_ec2/protocol_serde/
shape_import_snapshot.rs

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