aws-sdk-ec2 1.224.0

AWS SDK for Amazon Elastic Compute Cloud
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::unnecessary_wraps)]
pub fn de_restore_snapshot_from_recycle_bin_http_error(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<
    crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinOutput,
    crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinError,
> {
    #[allow(unused_mut)]
    let mut generic_builder = crate::protocol_serde::parse_http_error_metadata(_response_status, _response_headers, _response_body)
        .map_err(crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinError::unhandled)?;
    generic_builder = ::aws_types::request_id::apply_request_id(generic_builder, _response_headers);
    let generic = generic_builder.build();
    Err(crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinError::generic(generic))
}

#[allow(clippy::unnecessary_wraps)]
pub fn de_restore_snapshot_from_recycle_bin_http_response(
    _response_status: u16,
    _response_headers: &::aws_smithy_runtime_api::http::Headers,
    _response_body: &[u8],
) -> std::result::Result<
    crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinOutput,
    crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinError,
> {
    Ok({
        #[allow(unused_mut)]
        let mut output = crate::operation::restore_snapshot_from_recycle_bin::builders::RestoreSnapshotFromRecycleBinOutputBuilder::default();
        output = crate::protocol_serde::shape_restore_snapshot_from_recycle_bin::de_restore_snapshot_from_recycle_bin(_response_body, output)
            .map_err(crate::operation::restore_snapshot_from_recycle_bin::RestoreSnapshotFromRecycleBinError::unhandled)?;
        output._set_request_id(::aws_types::request_id::RequestId::request_id(_response_headers).map(str::to_string));
        output.build()
    })
}

#[allow(unused_mut)]
pub fn de_restore_snapshot_from_recycle_bin(
    inp: &[u8],
    mut builder: crate::operation::restore_snapshot_from_recycle_bin::builders::RestoreSnapshotFromRecycleBinOutputBuilder,
) -> std::result::Result<
    crate::operation::restore_snapshot_from_recycle_bin::builders::RestoreSnapshotFromRecycleBinOutputBuilder,
    ::aws_smithy_xml::decode::XmlDecodeError,
> {
    let mut doc = ::aws_smithy_xml::decode::Document::try_from(inp)?;

    #[allow(unused_mut)]
    let mut decoder = doc.root_element()?;
    #[allow(unused_variables)]
    let start_el = decoder.start_el();
    if !(start_el.matches("RestoreSnapshotFromRecycleBinResponse")) {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom(format!(
            "invalid root, expected RestoreSnapshotFromRecycleBinResponse got {start_el:?}"
        )));
    }
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("snapshotId") /* SnapshotId com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$SnapshotId */ =>  {
                let var_1 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_snapshot_id(var_1);
            }
            ,
            s if s.matches("outpostArn") /* OutpostArn com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$OutpostArn */ =>  {
                let var_2 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_outpost_arn(var_2);
            }
            ,
            s if s.matches("description") /* Description com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$Description */ =>  {
                let var_3 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_description(var_3);
            }
            ,
            s if s.matches("encrypted") /* Encrypted com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$Encrypted */ =>  {
                let var_4 =
                    Some(
                         {
                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.ec2#Boolean`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_encrypted(var_4);
            }
            ,
            s if s.matches("ownerId") /* OwnerId com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$OwnerId */ =>  {
                let var_5 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_owner_id(var_5);
            }
            ,
            s if s.matches("progress") /* Progress com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$Progress */ =>  {
                let var_6 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_progress(var_6);
            }
            ,
            s if s.matches("startTime") /* StartTime com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$StartTime */ =>  {
                let var_7 =
                    Some(
                        ::aws_smithy_types::DateTime::from_str(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
                        )
                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.ec2#MillisecondDateTime`)"))
                        ?
                    )
                ;
                builder = builder.set_start_time(var_7);
            }
            ,
            s if s.matches("status") /* State com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$State */ =>  {
                let var_8 =
                    Some(
                        Result::<crate::types::SnapshotState, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::SnapshotState::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_state(var_8);
            }
            ,
            s if s.matches("volumeId") /* VolumeId com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$VolumeId */ =>  {
                let var_9 =
                    Some(
                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            .into()
                        )
                        ?
                    )
                ;
                builder = builder.set_volume_id(var_9);
            }
            ,
            s if s.matches("volumeSize") /* VolumeSize com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$VolumeSize */ =>  {
                let var_10 =
                    Some(
                         {
                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.ec2#Integer`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_volume_size(var_10);
            }
            ,
            s if s.matches("sseType") /* SseType com.amazonaws.ec2.synthetic#RestoreSnapshotFromRecycleBinOutput$SseType */ =>  {
                let var_11 =
                    Some(
                        Result::<crate::types::SseType, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::SseType::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_sse_type(var_11);
            }
            ,
            _ => {}
        }
    }
    Ok(builder)
}