aws_sdk_s3/protocol_serde/
shape_inventory_s3_bucket_destination.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(clippy::needless_question_mark)]
3pub fn de_inventory_s3_bucket_destination(
4    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
5) -> ::std::result::Result<crate::types::InventoryS3BucketDestination, ::aws_smithy_xml::decode::XmlDecodeError> {
6    #[allow(unused_mut)]
7    let mut builder = crate::types::InventoryS3BucketDestination::builder();
8    while let Some(mut tag) = decoder.next_tag() {
9        match tag.start_el() {
10            s if s.matches("AccountId") /* AccountId com.amazonaws.s3#InventoryS3BucketDestination$AccountId */ =>  {
11                let var_1 =
12                    Some(
13                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
14                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
15                            .into()
16                        )
17                        ?
18                    )
19                ;
20                builder = builder.set_account_id(var_1);
21            }
22            ,
23            s if s.matches("Bucket") /* Bucket com.amazonaws.s3#InventoryS3BucketDestination$Bucket */ =>  {
24                let var_2 =
25                    Some(
26                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
27                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
28                            .into()
29                        )
30                        ?
31                    )
32                ;
33                builder = builder.set_bucket(var_2);
34            }
35            ,
36            s if s.matches("Format") /* Format com.amazonaws.s3#InventoryS3BucketDestination$Format */ =>  {
37                let var_3 =
38                    Some(
39                        Result::<crate::types::InventoryFormat, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
40                            crate::types::InventoryFormat::from(
41                                ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
42                            )
43                        )
44                        ?
45                    )
46                ;
47                builder = builder.set_format(var_3);
48            }
49            ,
50            s if s.matches("Prefix") /* Prefix com.amazonaws.s3#InventoryS3BucketDestination$Prefix */ =>  {
51                let var_4 =
52                    Some(
53                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
54                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
55                            .into()
56                        )
57                        ?
58                    )
59                ;
60                builder = builder.set_prefix(var_4);
61            }
62            ,
63            s if s.matches("Encryption") /* Encryption com.amazonaws.s3#InventoryS3BucketDestination$Encryption */ =>  {
64                let var_5 =
65                    Some(
66                        crate::protocol_serde::shape_inventory_encryption::de_inventory_encryption(&mut tag)
67                        ?
68                    )
69                ;
70                builder = builder.set_encryption(var_5);
71            }
72            ,
73            _ => {}
74        }
75    }
76    Ok(crate::serde_util::inventory_s3_bucket_destination_correct_errors(builder)
77        .build()
78        .map_err(|_| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing field"))?)
79}
80
81pub fn ser_inventory_s3_bucket_destination(
82    input: &crate::types::InventoryS3BucketDestination,
83    writer: ::aws_smithy_xml::encode::ElWriter,
84) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
85    #[allow(unused_mut)]
86    let mut scope = writer.finish();
87    if let Some(var_6) = &input.account_id {
88        let mut inner_writer = scope.start_el("AccountId").finish();
89        inner_writer.data(var_6.as_str());
90    }
91    {
92        let mut inner_writer = scope.start_el("Bucket").finish();
93        inner_writer.data(input.bucket.as_str());
94    }
95    {
96        let mut inner_writer = scope.start_el("Format").finish();
97        inner_writer.data(input.format.as_str());
98    }
99    if let Some(var_7) = &input.prefix {
100        let mut inner_writer = scope.start_el("Prefix").finish();
101        inner_writer.data(var_7.as_str());
102    }
103    if let Some(var_8) = &input.encryption {
104        let inner_writer = scope.start_el("Encryption");
105        crate::protocol_serde::shape_inventory_encryption::ser_inventory_encryption(var_8, inner_writer)?
106    }
107    scope.finish();
108    Ok(())
109}