aws_sdk_honeycode/types/
_table_data_import_job_status.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `TableDataImportJobStatus`, 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 tabledataimportjobstatus = unimplemented!();
14/// match tabledataimportjobstatus {
15///     TableDataImportJobStatus::Completed => { /* ... */ },
16///     TableDataImportJobStatus::Failed => { /* ... */ },
17///     TableDataImportJobStatus::InProgress => { /* ... */ },
18///     TableDataImportJobStatus::Submitted => { /* ... */ },
19///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
20///     _ => { /* ... */ },
21/// }
22/// ```
23/// The above code demonstrates that when `tabledataimportjobstatus` represents
24/// `NewFeature`, the execution path will lead to the second last match arm,
25/// even though the enum does not contain a variant `TableDataImportJobStatus::NewFeature`
26/// in the current version of SDK. The reason is that the variable `other`,
27/// created by the `@` operator, is bound to
28/// `TableDataImportJobStatus::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
29/// and calling `as_str` on it yields `"NewFeature"`.
30/// This match expression is forward-compatible when executed with a newer
31/// version of SDK where the variant `TableDataImportJobStatus::NewFeature` is defined.
32/// Specifically, when `tabledataimportjobstatus` represents `NewFeature`,
33/// the execution path will hit the second last match arm as before by virtue of
34/// calling `as_str` on `TableDataImportJobStatus::NewFeature` also yielding `"NewFeature"`.
35///
36/// Explicitly matching on the `Unknown` variant should
37/// be avoided for two reasons:
38/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
39/// - It might inadvertently shadow other intended match arms.
40#[allow(missing_docs)] // documentation missing in model
41#[non_exhaustive]
42#[derive(
43    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
44)]
45pub enum TableDataImportJobStatus {
46    #[allow(missing_docs)] // documentation missing in model
47    Completed,
48    #[allow(missing_docs)] // documentation missing in model
49    Failed,
50    #[allow(missing_docs)] // documentation missing in model
51    InProgress,
52    #[allow(missing_docs)] // documentation missing in model
53    Submitted,
54    /// `Unknown` contains new variants that have been added since this code was generated.
55    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
56    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
57}
58impl ::std::convert::From<&str> for TableDataImportJobStatus {
59    fn from(s: &str) -> Self {
60        match s {
61            "COMPLETED" => TableDataImportJobStatus::Completed,
62            "FAILED" => TableDataImportJobStatus::Failed,
63            "IN_PROGRESS" => TableDataImportJobStatus::InProgress,
64            "SUBMITTED" => TableDataImportJobStatus::Submitted,
65            other => TableDataImportJobStatus::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
66        }
67    }
68}
69impl ::std::str::FromStr for TableDataImportJobStatus {
70    type Err = ::std::convert::Infallible;
71
72    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
73        ::std::result::Result::Ok(TableDataImportJobStatus::from(s))
74    }
75}
76impl TableDataImportJobStatus {
77    /// Returns the `&str` value of the enum member.
78    pub fn as_str(&self) -> &str {
79        match self {
80            TableDataImportJobStatus::Completed => "COMPLETED",
81            TableDataImportJobStatus::Failed => "FAILED",
82            TableDataImportJobStatus::InProgress => "IN_PROGRESS",
83            TableDataImportJobStatus::Submitted => "SUBMITTED",
84            TableDataImportJobStatus::Unknown(value) => value.as_str(),
85        }
86    }
87    /// Returns all the `&str` representations of the enum members.
88    pub const fn values() -> &'static [&'static str] {
89        &["COMPLETED", "FAILED", "IN_PROGRESS", "SUBMITTED"]
90    }
91}
92impl ::std::convert::AsRef<str> for TableDataImportJobStatus {
93    fn as_ref(&self) -> &str {
94        self.as_str()
95    }
96}
97impl TableDataImportJobStatus {
98    /// Parses the enum value while disallowing unknown variants.
99    ///
100    /// Unknown variants will result in an error.
101    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
102        match Self::from(value) {
103            #[allow(deprecated)]
104            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
105            known => Ok(known),
106        }
107    }
108}
109impl ::std::fmt::Display for TableDataImportJobStatus {
110    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
111        match self {
112            TableDataImportJobStatus::Completed => write!(f, "COMPLETED"),
113            TableDataImportJobStatus::Failed => write!(f, "FAILED"),
114            TableDataImportJobStatus::InProgress => write!(f, "IN_PROGRESS"),
115            TableDataImportJobStatus::Submitted => write!(f, "SUBMITTED"),
116            TableDataImportJobStatus::Unknown(value) => write!(f, "{}", value),
117        }
118    }
119}