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