aws_sdk_nimble/types/
_studio_component_state.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `StudioComponentState`, 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 studiocomponentstate = unimplemented!();
14/// match studiocomponentstate {
15///     StudioComponentState::CreateFailed => { /* ... */ },
16///     StudioComponentState::CreateInProgress => { /* ... */ },
17///     StudioComponentState::Deleted => { /* ... */ },
18///     StudioComponentState::DeleteFailed => { /* ... */ },
19///     StudioComponentState::DeleteInProgress => { /* ... */ },
20///     StudioComponentState::Ready => { /* ... */ },
21///     StudioComponentState::UpdateFailed => { /* ... */ },
22///     StudioComponentState::UpdateInProgress => { /* ... */ },
23///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
24///     _ => { /* ... */ },
25/// }
26/// ```
27/// The above code demonstrates that when `studiocomponentstate` represents
28/// `NewFeature`, the execution path will lead to the second last match arm,
29/// even though the enum does not contain a variant `StudioComponentState::NewFeature`
30/// in the current version of SDK. The reason is that the variable `other`,
31/// created by the `@` operator, is bound to
32/// `StudioComponentState::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 `StudioComponentState::NewFeature` is defined.
36/// Specifically, when `studiocomponentstate` represents `NewFeature`,
37/// the execution path will hit the second last match arm as before by virtue of
38/// calling `as_str` on `StudioComponentState::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/// <p>The current state of the studio component resource.</p>
45/// <p>While a studio component is being created, modified, or deleted, its state will be
46/// <code>CREATE_IN_PROGRESS</code>, <code>UPDATE_IN_PROGRESS</code>, or
47/// <code>DELETE_IN_PROGRESS</code>.</p>
48/// <p>These are called <i>transition states</i>.</p>
49/// <p>No modifications may be made to the studio component while it is in a transition
50/// state.</p>
51/// <p>If creation of the resource fails, the state will change to
52/// <code>CREATE_FAILED</code>. The resource <code>StatusCode</code> and
53/// <code>StatusMessage</code> will provide more information of why creation failed. The
54/// resource in this state will automatically be deleted from your account after a period of
55/// time.</p>
56/// <p>If updating the resource fails, the state will change to <code>UPDATE_FAILED</code>.
57/// The resource <code>StatusCode</code> and <code>StatusMessage</code> will provide more
58/// information of why the update failed. The resource will be returned to the state it was
59/// in when the update request was invoked.</p>
60/// <p>If deleting the resource fails, the state will change to <code>DELETE_FAILED</code>.
61/// The resource <code>StatusCode</code> and <code>StatusMessage</code> will provide more
62/// information of why the update failed. The resource will be returned to the state it was
63/// in when the update request was invoked. After the resource is deleted successfully, it
64/// will change to the <code>DELETED</code> state. The resource will no longer count against
65/// service quotas and cannot be used or acted upon any futher. It will be removed from your
66/// account after a period of time.</p>
67#[non_exhaustive]
68#[derive(
69    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
70)]
71pub enum StudioComponentState {
72    #[allow(missing_docs)] // documentation missing in model
73    CreateFailed,
74    #[allow(missing_docs)] // documentation missing in model
75    CreateInProgress,
76    #[allow(missing_docs)] // documentation missing in model
77    Deleted,
78    #[allow(missing_docs)] // documentation missing in model
79    DeleteFailed,
80    #[allow(missing_docs)] // documentation missing in model
81    DeleteInProgress,
82    #[allow(missing_docs)] // documentation missing in model
83    Ready,
84    #[allow(missing_docs)] // documentation missing in model
85    UpdateFailed,
86    #[allow(missing_docs)] // documentation missing in model
87    UpdateInProgress,
88    /// `Unknown` contains new variants that have been added since this code was generated.
89    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
90    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
91}
92impl ::std::convert::From<&str> for StudioComponentState {
93    fn from(s: &str) -> Self {
94        match s {
95            "CREATE_FAILED" => StudioComponentState::CreateFailed,
96            "CREATE_IN_PROGRESS" => StudioComponentState::CreateInProgress,
97            "DELETED" => StudioComponentState::Deleted,
98            "DELETE_FAILED" => StudioComponentState::DeleteFailed,
99            "DELETE_IN_PROGRESS" => StudioComponentState::DeleteInProgress,
100            "READY" => StudioComponentState::Ready,
101            "UPDATE_FAILED" => StudioComponentState::UpdateFailed,
102            "UPDATE_IN_PROGRESS" => StudioComponentState::UpdateInProgress,
103            other => StudioComponentState::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
104        }
105    }
106}
107impl ::std::str::FromStr for StudioComponentState {
108    type Err = ::std::convert::Infallible;
109
110    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
111        ::std::result::Result::Ok(StudioComponentState::from(s))
112    }
113}
114impl StudioComponentState {
115    /// Returns the `&str` value of the enum member.
116    pub fn as_str(&self) -> &str {
117        match self {
118            StudioComponentState::CreateFailed => "CREATE_FAILED",
119            StudioComponentState::CreateInProgress => "CREATE_IN_PROGRESS",
120            StudioComponentState::Deleted => "DELETED",
121            StudioComponentState::DeleteFailed => "DELETE_FAILED",
122            StudioComponentState::DeleteInProgress => "DELETE_IN_PROGRESS",
123            StudioComponentState::Ready => "READY",
124            StudioComponentState::UpdateFailed => "UPDATE_FAILED",
125            StudioComponentState::UpdateInProgress => "UPDATE_IN_PROGRESS",
126            StudioComponentState::Unknown(value) => value.as_str(),
127        }
128    }
129    /// Returns all the `&str` representations of the enum members.
130    pub const fn values() -> &'static [&'static str] {
131        &[
132            "CREATE_FAILED",
133            "CREATE_IN_PROGRESS",
134            "DELETED",
135            "DELETE_FAILED",
136            "DELETE_IN_PROGRESS",
137            "READY",
138            "UPDATE_FAILED",
139            "UPDATE_IN_PROGRESS",
140        ]
141    }
142}
143impl ::std::convert::AsRef<str> for StudioComponentState {
144    fn as_ref(&self) -> &str {
145        self.as_str()
146    }
147}
148impl StudioComponentState {
149    /// Parses the enum value while disallowing unknown variants.
150    ///
151    /// Unknown variants will result in an error.
152    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
153        match Self::from(value) {
154            #[allow(deprecated)]
155            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
156            known => Ok(known),
157        }
158    }
159}
160impl ::std::fmt::Display for StudioComponentState {
161    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
162        match self {
163            StudioComponentState::CreateFailed => write!(f, "CREATE_FAILED"),
164            StudioComponentState::CreateInProgress => write!(f, "CREATE_IN_PROGRESS"),
165            StudioComponentState::Deleted => write!(f, "DELETED"),
166            StudioComponentState::DeleteFailed => write!(f, "DELETE_FAILED"),
167            StudioComponentState::DeleteInProgress => write!(f, "DELETE_IN_PROGRESS"),
168            StudioComponentState::Ready => write!(f, "READY"),
169            StudioComponentState::UpdateFailed => write!(f, "UPDATE_FAILED"),
170            StudioComponentState::UpdateInProgress => write!(f, "UPDATE_IN_PROGRESS"),
171            StudioComponentState::Unknown(value) => write!(f, "{}", value),
172        }
173    }
174}