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