aws-sdk-ec2 1.232.1

AWS SDK for Amazon Elastic Compute Cloud
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[allow(clippy::needless_question_mark)]
pub fn de_cancellation_terms(
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
    depth: u32,
) -> ::std::result::Result<crate::types::CancellationTerms, ::aws_smithy_xml::decode::XmlDecodeError> {
    if depth >= 128u32 {
        return Err(::aws_smithy_xml::decode::XmlDecodeError::custom("maximum nesting depth exceeded"));
    }
    #[allow(unused_mut)]
    let mut builder = crate::types::CancellationTerms::builder();
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("cancellationType") /* CancellationType com.amazonaws.ec2#CancellationTerms$CancellationType */ =>  {
                let var_1 =
                    Some(
                        Result::<crate::types::ApplyCancellationCharges, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::ApplyCancellationCharges::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_cancellation_type(var_1);
            }
            ,
            s if s.matches("reservationState") /* ReservationState com.amazonaws.ec2#CancellationTerms$ReservationState */ =>  {
                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_reservation_state(var_2);
            }
            ,
            s if s.matches("committedInstanceCount") /* CommittedInstanceCount com.amazonaws.ec2#CancellationTerms$CommittedInstanceCount */ =>  {
                let var_3 =
                    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#BoxedInteger`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_committed_instance_count(var_3);
            }
            ,
            s if s.matches("chargeCommitmentDurationHours") /* ChargeCommitmentDurationHours com.amazonaws.ec2#CancellationTerms$ChargeCommitmentDurationHours */ =>  {
                let var_4 =
                    Some(
                         {
                            <i64 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 (long: `com.amazonaws.ec2#BoxedLong`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_charge_commitment_duration_hours(var_4);
            }
            ,
            s if s.matches("chargeEndDate") /* ChargeEndDate com.amazonaws.ec2#CancellationTerms$ChargeEndDate */ =>  {
                let var_5 =
                    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_charge_end_date(var_5);
            }
            ,
            _ => {}
        }
    }
    Ok(builder.build())
}