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