aws_sdk_s3/protocol_serde/
shape_object_lock_retention.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_object_lock_retention(
3    input: &crate::types::ObjectLockRetention,
4    writer: ::aws_smithy_xml::encode::ElWriter,
5) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
6    #[allow(unused_mut)]
7    let mut scope = writer.finish();
8    if let Some(var_1) = &input.mode {
9        let mut inner_writer = scope.start_el("Mode").finish();
10        inner_writer.data(var_1.as_str());
11    }
12    if let Some(var_2) = &input.retain_until_date {
13        let mut inner_writer = scope.start_el("RetainUntilDate").finish();
14        inner_writer.data(var_2.fmt(::aws_smithy_types::date_time::Format::DateTimeWithOffset)?.as_ref());
15    }
16    scope.finish();
17    Ok(())
18}
19
20#[allow(clippy::needless_question_mark)]
21pub fn de_object_lock_retention(
22    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
23) -> ::std::result::Result<crate::types::ObjectLockRetention, ::aws_smithy_xml::decode::XmlDecodeError> {
24    #[allow(unused_mut)]
25    let mut builder = crate::types::ObjectLockRetention::builder();
26    while let Some(mut tag) = decoder.next_tag() {
27        match tag.start_el() {
28            s if s.matches("Mode") /* Mode com.amazonaws.s3#ObjectLockRetention$Mode */ =>  {
29                let var_3 =
30                    Some(
31                        Result::<crate::types::ObjectLockRetentionMode, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
32                            crate::types::ObjectLockRetentionMode::from(
33                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
34                            )
35                        )
36                        ?
37                    )
38                ;
39                builder = builder.set_mode(var_3);
40            }
41            ,
42            s if s.matches("RetainUntilDate") /* RetainUntilDate com.amazonaws.s3#ObjectLockRetention$RetainUntilDate */ =>  {
43                let var_4 =
44                    Some(
45                        ::aws_smithy_types::DateTime::from_str(
46                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
47                            , ::aws_smithy_types::date_time::Format::DateTimeWithOffset
48                        )
49                        .map_err(|_|::aws_smithy_xml::decode::XmlDecodeError::custom("expected (timestamp: `com.amazonaws.s3#Date`)"))
50                        ?
51                    )
52                ;
53                builder = builder.set_retain_until_date(var_4);
54            }
55            ,
56            _ => {}
57        }
58    }
59    Ok(builder.build())
60}