Skip to main content

aws_sdk_glue/types/
_glue_record_type.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `GlueRecordType`, it is important to ensure
4/// your code is forward-compatible. That is, if a match arm handles a case for a
5/// feature that is supported by the service but has not been represented as an enum
6/// variant in a current version of SDK, your code should continue to work when you
7/// upgrade SDK to a future version in which the enum does include a variant for that
8/// feature.
9///
10/// Here is an example of how you can make a match expression forward-compatible:
11///
12/// ```text
13/// # let gluerecordtype = unimplemented!();
14/// match gluerecordtype {
15///     GlueRecordType::Bigdecimal => { /* ... */ },
16///     GlueRecordType::Byte => { /* ... */ },
17///     GlueRecordType::Date => { /* ... */ },
18///     GlueRecordType::Double => { /* ... */ },
19///     GlueRecordType::Float => { /* ... */ },
20///     GlueRecordType::Int => { /* ... */ },
21///     GlueRecordType::Long => { /* ... */ },
22///     GlueRecordType::Short => { /* ... */ },
23///     GlueRecordType::String => { /* ... */ },
24///     GlueRecordType::Timestamp => { /* ... */ },
25///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
26///     _ => { /* ... */ },
27/// }
28/// ```
29/// The above code demonstrates that when `gluerecordtype` represents
30/// `NewFeature`, the execution path will lead to the second last match arm,
31/// even though the enum does not contain a variant `GlueRecordType::NewFeature`
32/// in the current version of SDK. The reason is that the variable `other`,
33/// created by the `@` operator, is bound to
34/// `GlueRecordType::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
35/// and calling `as_str` on it yields `"NewFeature"`.
36/// This match expression is forward-compatible when executed with a newer
37/// version of SDK where the variant `GlueRecordType::NewFeature` is defined.
38/// Specifically, when `gluerecordtype` represents `NewFeature`,
39/// the execution path will hit the second last match arm as before by virtue of
40/// calling `as_str` on `GlueRecordType::NewFeature` also yielding `"NewFeature"`.
41///
42/// Explicitly matching on the `Unknown` variant should
43/// be avoided for two reasons:
44/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
45/// - It might inadvertently shadow other intended match arms.
46///
47#[allow(missing_docs)] // documentation missing in model
48#[non_exhaustive]
49#[derive(
50    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
51)]
52pub enum GlueRecordType {
53    #[allow(missing_docs)] // documentation missing in model
54    Bigdecimal,
55    #[allow(missing_docs)] // documentation missing in model
56    Byte,
57    #[allow(missing_docs)] // documentation missing in model
58    Date,
59    #[allow(missing_docs)] // documentation missing in model
60    Double,
61    #[allow(missing_docs)] // documentation missing in model
62    Float,
63    #[allow(missing_docs)] // documentation missing in model
64    Int,
65    #[allow(missing_docs)] // documentation missing in model
66    Long,
67    #[allow(missing_docs)] // documentation missing in model
68    Short,
69    #[allow(missing_docs)] // documentation missing in model
70    String,
71    #[allow(missing_docs)] // documentation missing in model
72    Timestamp,
73    /// `Unknown` contains new variants that have been added since this code was generated.
74    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
75    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
76}
77impl ::std::convert::From<&str> for GlueRecordType {
78    fn from(s: &str) -> Self {
79        match s {
80            "BIGDECIMAL" => GlueRecordType::Bigdecimal,
81            "BYTE" => GlueRecordType::Byte,
82            "DATE" => GlueRecordType::Date,
83            "DOUBLE" => GlueRecordType::Double,
84            "FLOAT" => GlueRecordType::Float,
85            "INT" => GlueRecordType::Int,
86            "LONG" => GlueRecordType::Long,
87            "SHORT" => GlueRecordType::Short,
88            "STRING" => GlueRecordType::String,
89            "TIMESTAMP" => GlueRecordType::Timestamp,
90            other => GlueRecordType::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
91        }
92    }
93}
94impl ::std::str::FromStr for GlueRecordType {
95    type Err = ::std::convert::Infallible;
96
97    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
98        ::std::result::Result::Ok(GlueRecordType::from(s))
99    }
100}
101impl GlueRecordType {
102    /// Returns the `&str` value of the enum member.
103    pub fn as_str(&self) -> &str {
104        match self {
105            GlueRecordType::Bigdecimal => "BIGDECIMAL",
106            GlueRecordType::Byte => "BYTE",
107            GlueRecordType::Date => "DATE",
108            GlueRecordType::Double => "DOUBLE",
109            GlueRecordType::Float => "FLOAT",
110            GlueRecordType::Int => "INT",
111            GlueRecordType::Long => "LONG",
112            GlueRecordType::Short => "SHORT",
113            GlueRecordType::String => "STRING",
114            GlueRecordType::Timestamp => "TIMESTAMP",
115            GlueRecordType::Unknown(value) => value.as_str(),
116        }
117    }
118    /// Returns all the `&str` representations of the enum members.
119    pub const fn values() -> &'static [&'static str] {
120        &[
121            "BIGDECIMAL",
122            "BYTE",
123            "DATE",
124            "DOUBLE",
125            "FLOAT",
126            "INT",
127            "LONG",
128            "SHORT",
129            "STRING",
130            "TIMESTAMP",
131        ]
132    }
133}
134impl ::std::convert::AsRef<str> for GlueRecordType {
135    fn as_ref(&self) -> &str {
136        self.as_str()
137    }
138}
139impl GlueRecordType {
140    /// Parses the enum value while disallowing unknown variants.
141    ///
142    /// Unknown variants will result in an error.
143    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
144        match Self::from(value) {
145            #[allow(deprecated)]
146            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
147            known => Ok(known),
148        }
149    }
150}
151impl ::std::fmt::Display for GlueRecordType {
152    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
153        match self {
154            GlueRecordType::Bigdecimal => write!(f, "BIGDECIMAL"),
155            GlueRecordType::Byte => write!(f, "BYTE"),
156            GlueRecordType::Date => write!(f, "DATE"),
157            GlueRecordType::Double => write!(f, "DOUBLE"),
158            GlueRecordType::Float => write!(f, "FLOAT"),
159            GlueRecordType::Int => write!(f, "INT"),
160            GlueRecordType::Long => write!(f, "LONG"),
161            GlueRecordType::Short => write!(f, "SHORT"),
162            GlueRecordType::String => write!(f, "STRING"),
163            GlueRecordType::Timestamp => write!(f, "TIMESTAMP"),
164            GlueRecordType::Unknown(value) => write!(f, "{value}"),
165        }
166    }
167}