aws_sdk_ec2/protocol_serde/
shape_attach_volume.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::unnecessary_wraps)]
3pub fn de_attach_volume_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::attach_volume::AttachVolumeOutput, crate::operation::attach_volume::AttachVolumeError> {
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::attach_volume::AttachVolumeError::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::attach_volume::AttachVolumeError::generic(generic))
14}
15
16#[allow(clippy::unnecessary_wraps)]
17pub fn de_attach_volume_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::attach_volume::AttachVolumeOutput, crate::operation::attach_volume::AttachVolumeError> {
22    Ok({
23        #[allow(unused_mut)]
24        let mut output = crate::operation::attach_volume::builders::AttachVolumeOutputBuilder::default();
25        output = crate::protocol_serde::shape_attach_volume::de_attach_volume(_response_body, output)
26            .map_err(crate::operation::attach_volume::AttachVolumeError::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_attach_volume(
34    inp: &[u8],
35    mut builder: crate::operation::attach_volume::builders::AttachVolumeOutputBuilder,
36) -> std::result::Result<crate::operation::attach_volume::builders::AttachVolumeOutputBuilder, ::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("AttachVolumeResponse")) {
44        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
45            "invalid root, expected AttachVolumeResponse 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("deleteOnTermination") /* DeleteOnTermination com.amazonaws.ec2.synthetic#AttachVolumeOutput$DeleteOnTermination */ =>  {
52                let var_1 =
53                    Some(
54                         {
55                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
56                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
57                            )
58                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
59                        }
60                        ?
61                    )
62                ;
63                builder = builder.set_delete_on_termination(var_1);
64            }
65            ,
66            s if s.matches("associatedResource") /* AssociatedResource com.amazonaws.ec2.synthetic#AttachVolumeOutput$AssociatedResource */ =>  {
67                let var_2 =
68                    Some(
69                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
70                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
71                            .into()
72                        )
73                        ?
74                    )
75                ;
76                builder = builder.set_associated_resource(var_2);
77            }
78            ,
79            s if s.matches("instanceOwningService") /* InstanceOwningService com.amazonaws.ec2.synthetic#AttachVolumeOutput$InstanceOwningService */ =>  {
80                let var_3 =
81                    Some(
82                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
83                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
84                            .into()
85                        )
86                        ?
87                    )
88                ;
89                builder = builder.set_instance_owning_service(var_3);
90            }
91            ,
92            s if s.matches("volumeId") /* VolumeId com.amazonaws.ec2.synthetic#AttachVolumeOutput$VolumeId */ =>  {
93                let var_4 =
94                    Some(
95                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
96                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
97                            .into()
98                        )
99                        ?
100                    )
101                ;
102                builder = builder.set_volume_id(var_4);
103            }
104            ,
105            s if s.matches("instanceId") /* InstanceId com.amazonaws.ec2.synthetic#AttachVolumeOutput$InstanceId */ =>  {
106                let var_5 =
107                    Some(
108                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
109                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
110                            .into()
111                        )
112                        ?
113                    )
114                ;
115                builder = builder.set_instance_id(var_5);
116            }
117            ,
118            s if s.matches("device") /* Device com.amazonaws.ec2.synthetic#AttachVolumeOutput$Device */ =>  {
119                let var_6 =
120                    Some(
121                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
122                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
123                            .into()
124                        )
125                        ?
126                    )
127                ;
128                builder = builder.set_device(var_6);
129            }
130            ,
131            s if s.matches("status") /* State com.amazonaws.ec2.synthetic#AttachVolumeOutput$State */ =>  {
132                let var_7 =
133                    Some(
134                        Result::<crate::types::VolumeAttachmentState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
135                            crate::types::VolumeAttachmentState::from(
136                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
137                            )
138                        )
139                        ?
140                    )
141                ;
142                builder = builder.set_state(var_7);
143            }
144            ,
145            s if s.matches("attachTime") /* AttachTime com.amazonaws.ec2.synthetic#AttachVolumeOutput$AttachTime */ =>  {
146                let var_8 =
147                    Some(
148                        ::aws_smithy_types::DateTime::from_str(
149                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
150                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
151                        )
152                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#DateTime`)"))
153                        ?
154                    )
155                ;
156                builder = builder.set_attach_time(var_8);
157            }
158            ,
159            _ => {}
160        }
161    }
162    Ok(builder)
163}