Skip to main content

aws_sdk_glue/schema_serde/
shape_table_optimizer_vpc_configuration.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2static TABLEOPTIMIZERVPCCONFIGURATION_MEMBER_GLUECONNECTIONNAME: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
3    ::aws_smithy_schema::ShapeId::from_parts(
4        "com.amazonaws.glue#TableOptimizerVpcConfiguration$glueConnectionName",
5        "com.amazonaws.glue",
6        "TableOptimizerVpcConfiguration",
7    ),
8    ::aws_smithy_schema::ShapeType::String,
9    "glueConnectionName",
10    0,
11);
12static TABLEOPTIMIZERVPCCONFIGURATION_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
13    ::aws_smithy_schema::ShapeId::from_parts(
14        "com.amazonaws.glue#TableOptimizerVpcConfiguration",
15        "com.amazonaws.glue",
16        "TableOptimizerVpcConfiguration",
17    ),
18    ::aws_smithy_schema::ShapeType::Union,
19    &[&TABLEOPTIMIZERVPCCONFIGURATION_MEMBER_GLUECONNECTIONNAME],
20);
21impl crate::types::TableOptimizerVpcConfiguration {
22    /// The schema for this shape.
23    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &TABLEOPTIMIZERVPCCONFIGURATION_SCHEMA;
24}
25impl ::aws_smithy_schema::serde::SerializableStruct for crate::types::TableOptimizerVpcConfiguration {
26    fn schema(&self) -> &::aws_smithy_schema::Schema<'_> {
27        Self::SCHEMA
28    }
29
30    #[allow(unused_variables, clippy::diverging_sub_expression)]
31    fn serialize_members(
32        &self,
33        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
34    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
35        match self {
36            Self::GlueConnectionName(val) => {
37                ser.write_string(&TABLEOPTIMIZERVPCCONFIGURATION_MEMBER_GLUECONNECTIONNAME, val)?;
38            }
39            Self::Unknown => return Err(::aws_smithy_schema::serde::SerdeError::custom("cannot serialize unknown union variant")),
40        }
41        Ok(())
42    }
43}
44impl crate::types::TableOptimizerVpcConfiguration {
45    /// Deserializes this union from a [`ShapeDeserializer`].
46    pub fn deserialize(
47        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
48    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
49        let mut result: ::std::option::Option<Self> = ::std::option::Option::None;
50        #[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding)]
51        deserializer.read_struct(&TABLEOPTIMIZERVPCCONFIGURATION_SCHEMA, &mut |member, deser| {
52            // A union holds exactly one member; the deserializer reports every key
53            // (known or not), so a second one is an error whatever it names.
54            if result.is_some() {
55                return Err(::aws_smithy_schema::serde::SerdeError::invalid_input(
56                    "encountered mixed variants in union",
57                ));
58            }
59            result = ::std::option::Option::Some(match member.member_index() {
60                Some(0) => Self::GlueConnectionName(deser.read_string(member)?),
61                _ => Self::Unknown,
62            });
63            Ok(())
64        })?;
65        result.ok_or_else(|| ::aws_smithy_schema::serde::SerdeError::custom("expected a union variant"))
66    }
67}