aws_sdk_s3/protocol_serde/
shape_default_retention.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_default_retention(
    input: &crate::types::DefaultRetention,
    writer: ::aws_smithy_xml::encode::ElWriter,
) -> Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    #[allow(unused_mut)]
    let mut scope = writer.finish();
    if let Some(var_1) = &input.mode {
        let mut inner_writer = scope.start_el("Mode").finish();
        inner_writer.data(var_1.as_str());
    }
    if let Some(var_2) = &input.days {
        let mut inner_writer = scope.start_el("Days").finish();
        inner_writer.data(::aws_smithy_types::primitive::Encoder::from(*var_2).encode());
    }
    if let Some(var_3) = &input.years {
        let mut inner_writer = scope.start_el("Years").finish();
        inner_writer.data(::aws_smithy_types::primitive::Encoder::from(*var_3).encode());
    }
    scope.finish();
    Ok(())
}

#[allow(clippy::needless_question_mark)]
pub fn de_default_retention(
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
) -> Result<crate::types::DefaultRetention, ::aws_smithy_xml::decode::XmlDecodeError> {
    #[allow(unused_mut)]
    let mut builder = crate::types::DefaultRetention::builder();
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("Mode") /* Mode com.amazonaws.s3#DefaultRetention$Mode */ =>  {
                let var_4 =
                    Some(
                        Result::<crate::types::ObjectLockRetentionMode, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                            crate::types::ObjectLockRetentionMode::from(
                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                            )
                        )
                        ?
                    )
                ;
                builder = builder.set_mode(var_4);
            }
            ,
            s if s.matches("Days") /* Days com.amazonaws.s3#DefaultRetention$Days */ =>  {
                let var_5 =
                    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.s3#Days`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_days(var_5);
            }
            ,
            s if s.matches("Years") /* Years com.amazonaws.s3#DefaultRetention$Years */ =>  {
                let var_6 =
                    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.s3#Years`)"))
                        }
                        ?
                    )
                ;
                builder = builder.set_years(var_6);
            }
            ,
            _ => {}
        }
    }
    Ok(builder.build())
}