aws-sdk-interconnect 1.1.0

AWS SDK for Interconnect
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn ser_attach_point(
    encoder: &mut ::aws_smithy_cbor::Encoder,
    input: &crate::types::AttachPoint,
) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::SerializationError> {
    encoder.map(1);
    match input {
        crate::types::AttachPoint::DirectConnectGateway(inner) => {
            encoder.str("directConnectGateway").str(inner.as_str());
        }
        crate::types::AttachPoint::Arn(inner) => {
            encoder.str("arn").str(inner.as_str());
        }
        crate::types::AttachPoint::Unknown => {
            return ::std::result::Result::Err(::aws_smithy_types::error::operation::SerializationError::unknown_variant("AttachPoint"))
        }
    }
    ::std::result::Result::Ok(())
}

pub(crate) fn de_attach_point(
    decoder: &mut ::aws_smithy_cbor::Decoder,
) -> ::std::result::Result<crate::types::AttachPoint, ::aws_smithy_cbor::decode::DeserializeError> {
    fn pair(
        decoder: &mut ::aws_smithy_cbor::Decoder,
    ) -> ::std::result::Result<crate::types::AttachPoint, ::aws_smithy_cbor::decode::DeserializeError> {
        Ok(match decoder.str()?.as_ref() {
            "directConnectGateway" => crate::types::AttachPoint::DirectConnectGateway(decoder.string()?),
            "arn" => crate::types::AttachPoint::Arn(decoder.string()?),
            _ => {
                decoder.skip()?;
                crate::types::AttachPoint::Unknown
            }
        })
    }

    match decoder.map()? {
        None => {
            let variant = pair(decoder)?;
            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),
        Some(_) => Err(::aws_smithy_cbor::decode::DeserializeError::mixed_union_variants(decoder.position())),
    }
}