Skip to main content

aws_sdk_config/types/
_organization_rule_status.rs

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