Skip to main content

aws_sdk_cloudfront/protocol_serde/
shape_tag.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub fn ser_tag(
3    input: &crate::types::Tag,
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    {
9        let mut inner_writer = scope.start_el("Key").finish();
10        inner_writer.data(input.key.as_str());
11    }
12    if let Some(var_1) = &input.value {
13        let mut inner_writer = scope.start_el("Value").finish();
14        inner_writer.data(var_1.as_str());
15    }
16    scope.finish();
17    Ok(())
18}
19
20#[allow(clippy::needless_question_mark)]
21pub fn de_tag(
22    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
23) -> ::std::result::Result<crate::types::Tag, ::aws_smithy_xml::decode::XmlDecodeError> {
24    #[allow(unused_mut)]
25    let mut builder = crate::types::Tag::builder();
26    while let Some(mut tag) = decoder.next_tag() {
27        match tag.start_el() {
28            s if s.matches("Key") /* Key com.amazonaws.cloudfront#Tag$Key */ =>  {
29                let var_2 =
30                    Some(
31                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
32                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
33                            .into()
34                        )
35                        ?
36                    )
37                ;
38                builder = builder.set_key(var_2);
39            }
40            ,
41            s if s.matches("Value") /* Value com.amazonaws.cloudfront#Tag$Value */ =>  {
42                let var_3 =
43                    Some(
44                        Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
45                            ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
46                            .into()
47                        )
48                        ?
49                    )
50                ;
51                builder = builder.set_value(var_3);
52            }
53            ,
54            _ => {}
55        }
56    }
57    Ok(crate::serde_util::tag_correct_errors(builder)
58        .build()
59        .map_err(|_| ::aws_smithy_xml::decode::XmlDecodeError::custom("missing field"))?)
60}