// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn de_analytics_filter(
    decoder: &mut ::aws_smithy_xml::decode::ScopedDecoder,
) -> ::std::result::Result<crate::types::AnalyticsFilter, ::aws_smithy_xml::decode::XmlDecodeError> {
    let mut base: Option<crate::types::AnalyticsFilter> = None;
    while let Some(mut tag) = decoder.next_tag() {
        match tag.start_el() {
            s if s.matches("Prefix") /* Prefix com.amazonaws.s3#AnalyticsFilter$Prefix */ =>  {
                let tmp =
                    Result::<::std::string::String, ::aws_smithy_xml::decode::XmlDecodeError>::Ok(
                        ::aws_smithy_xml::decode::try_data(&mut tag)?.as_ref()
                        .into()
                    )
                    ?
                ;
                base = Some(crate::types::AnalyticsFilter::Prefix(tmp));
            }
            ,
            s if s.matches("Tag") /* Tag com.amazonaws.s3#AnalyticsFilter$Tag */ =>  {
                let tmp =
                    crate::protocol_serde::shape_tag::de_tag(&mut tag)
                    ?
                ;
                base = Some(crate::types::AnalyticsFilter::Tag(tmp));
            }
            ,
            s if s.matches("And") /* And com.amazonaws.s3#AnalyticsFilter$And */ =>  {
                let tmp =
                    crate::protocol_serde::shape_analytics_and_operator::de_analytics_and_operator(&mut tag)
                    ?
                ;
                base = Some(crate::types::AnalyticsFilter::And(tmp));
            }
            ,
            _unknown => base = Some(crate::types::AnalyticsFilter::Unknown),
        }
    }
    base.ok_or_else(|| ::aws_smithy_xml::decode::XmlDecodeError::custom("expected union, got nothing"))
}

pub fn ser_analytics_filter(
    input: &crate::types::AnalyticsFilter,
    writer: ::aws_smithy_xml::encode::ElWriter,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    let mut scope_writer = writer.finish();
    match input {
        crate::types::AnalyticsFilter::Prefix(inner) => {
            let mut inner_writer = scope_writer.start_el("Prefix").finish();
            inner_writer.data(inner.as_str());
        }
        crate::types::AnalyticsFilter::Tag(inner) => {
            let inner_writer = scope_writer.start_el("Tag");
            crate::protocol_serde::shape_tag::ser_tag(inner, inner_writer)?
        }
        crate::types::AnalyticsFilter::And(inner) => {
            let inner_writer = scope_writer.start_el("And");
            crate::protocol_serde::shape_analytics_and_operator::ser_analytics_and_operator(inner, inner_writer)?
        }
        crate::types::AnalyticsFilter::Unknown => {
            return Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "AnalyticsFilter",
            ))
        }
    }
    Ok(())
}
