aws_sdk_s3/protocol_serde/
shape_lifecycle_expiration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_lifecycle_expiration(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::LifecycleExpiration, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::LifecycleExpiration::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("Date") /* Date com.amazonaws.s3#LifecycleExpiration$Date */ =>  {
11                let var_1 =
12                    Some(
13                        ::aws_smithy_types::DateTime::from_str(
14                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
15                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
16                        )
17                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.s3#Date`)"))
18                        ?
19                    )
20                ;
21                builder = builder.set_date(var_1);
22            }
23            ,
24            s if s.matches("Days") /* Days com.amazonaws.s3#LifecycleExpiration$Days */ =>  {
25                let var_2 =
26                    Some(
27                         {
28                            <i32 as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
29                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
30                            )
31                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (integer: `com.amazonaws.s3#Days`)"))
32                        }
33                        ?
34                    )
35                ;
36                builder = builder.set_days(var_2);
37            }
38            ,
39            s if s.matches("ExpiredObjectDeleteMarker") /* ExpiredObjectDeleteMarker com.amazonaws.s3#LifecycleExpiration$ExpiredObjectDeleteMarker */ =>  {
40                let var_3 =
41                    Some(
42                         {
43                            <bool as ::aws_smithy_types::primitive::Parse>::parse_smithy_primitive(
44                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
45                            )
46                            .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (boolean: `com.amazonaws.s3#ExpiredObjectDeleteMarker`)"))
47                        }
48                        ?
49                    )
50                ;
51                builder = builder.set_expired_object_delete_marker(var_3);
52            }
53            ,
54            _ => {}
55        }
56    }
57    Ok(builder.build())
58}
59
60pub fn ser_lifecycle_expiration(
61    input: &crate::types::LifecycleExpiration,
62    writer: ::aws_smithy_xml::encode::ElWriter,
63) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
64    #[allow(unused_mut)]
65    let mut scope = writer.finish();
66    if let Some(var_4) = &input.date {
67        let mut inner_writer = scope.start_el("Date").finish();
68        inner_writer.data(var_4.fmt(::aws_smithy_types::date_time::Format::DateTimeWithOffset)?.as_ref());
69    }
70    if let Some(var_5) = &input.days {
71        let mut inner_writer = scope.start_el("Days").finish();
72        inner_writer.data(::aws_smithy_types::primitive::Encoder::from(*var_5).encode());
73    }
74    if let Some(var_6) = &input.expired_object_delete_marker {
75        let mut inner_writer = scope.start_el("ExpiredObjectDeleteMarker").finish();
76        inner_writer.data(::aws_smithy_types::primitive::Encoder::from(*var_6).encode());
77    }
78    scope.finish();
79    Ok(())
80}