aws-sdk-eventbridgev2 1.2.0

AWS SDK for Amazon EventBridgeV2
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_event_source_configuration(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    input: &crate::types::EventSourceConfiguration,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.map(1);
    match input {
        crate::types::EventSourceConfiguration::AwsServiceEventsConfiguration(inner) => {
            encoder.str("AwsServiceEventsConfiguration");
            crate::protocol_serde::shape_aws_service_events_source_configuration::ser_aws_service_events_source_configuration(encoder, inner)?;
        }
        crate::types::EventSourceConfiguration::PartnerEventsConfiguration(inner) => {
            encoder.str("PartnerEventsConfiguration");
            crate::protocol_serde::shape_partner_events_source_configuration::ser_partner_events_source_configuration(encoder, inner)?;
        }
        crate::types::EventSourceConfiguration::Unknown => {
            return ::std::result::Result::Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant(
                "EventSourceConfiguration",
            ))
        }
    }
    ::std::result::Result::Ok(())
}

pub(crate) fn de_event_source_configuration(
    decoder: &mut ::aws_smithy_cbor::Decoder,
    depth: u32,
) -> ::std::result::Result<crate::types::EventSourceConfiguration, ::aws_smithy_cbor::decode::DeserializeError> {
    if depth >= 128u32 {
        return Err(::aws_smithy_cbor::decode::DeserializeError::custom(
            "maximum nesting depth exceeded",
            decoder.position(),
        ));
    }

    #[allow(unused_variables)]
    fn pair(
        decoder: &mut ::aws_smithy_cbor::Decoder,
        depth: u32,
    ) -> ::std::result::Result<crate::types::EventSourceConfiguration, ::aws_smithy_cbor::decode::DeserializeError> {
        Ok(match decoder.str()?.as_ref() {
            "AwsServiceEventsConfiguration" => crate::types::EventSourceConfiguration::AwsServiceEventsConfiguration(
                crate::protocol_serde::shape_aws_service_events_source_configuration::de_aws_service_events_source_configuration(decoder, depth + 1)?,
            ),
            "PartnerEventsConfiguration" => crate::types::EventSourceConfiguration::PartnerEventsConfiguration(
                crate::protocol_serde::shape_partner_events_source_configuration::de_partner_events_source_configuration(decoder, depth + 1)?,
            ),
            _ => {
                decoder.skip()?;
                crate::types::EventSourceConfiguration::Unknown
            }
        })
    }

    match decoder.map()? {
        None => {
            let variant = pair(decoder, depth)?;
            match decoder.datatype()? {
                ::aws_smithy_cbor::data::Type::Break => {
                    decoder.skip()?;
                    Ok(variant)
                }
                ty => Err(::aws_smithy_cbor::decode::DeserializeError::unexpected_union_variant(
                    ty,
                    decoder.position(),
                )),
            }
        }
        Some(1) => pair(decoder, depth),
        Some(_) => Err(::aws_smithy_cbor::decode::DeserializeError::mixed_union_variants(decoder.position())),
    }
}