aws_sdk_sms/types/
_replication_job_state.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `ReplicationJobState`, 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 replicationjobstate = unimplemented!();
14/// match replicationjobstate {
15///     ReplicationJobState::Active => { /* ... */ },
16///     ReplicationJobState::Completed => { /* ... */ },
17///     ReplicationJobState::Deleted => { /* ... */ },
18///     ReplicationJobState::Deleting => { /* ... */ },
19///     ReplicationJobState::Failed => { /* ... */ },
20///     ReplicationJobState::Failing => { /* ... */ },
21///     ReplicationJobState::PausedOnFailure => { /* ... */ },
22///     ReplicationJobState::Pending => { /* ... */ },
23///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
24///     _ => { /* ... */ },
25/// }
26/// ```
27/// The above code demonstrates that when `replicationjobstate` represents
28/// `NewFeature`, the execution path will lead to the second last match arm,
29/// even though the enum does not contain a variant `ReplicationJobState::NewFeature`
30/// in the current version of SDK. The reason is that the variable `other`,
31/// created by the `@` operator, is bound to
32/// `ReplicationJobState::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 `ReplicationJobState::NewFeature` is defined.
36/// Specifically, when `replicationjobstate` represents `NewFeature`,
37/// the execution path will hit the second last match arm as before by virtue of
38/// calling `as_str` on `ReplicationJobState::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 ReplicationJobState {
51    #[allow(missing_docs)] // documentation missing in model
52    Active,
53    #[allow(missing_docs)] // documentation missing in model
54    Completed,
55    #[allow(missing_docs)] // documentation missing in model
56    Deleted,
57    #[allow(missing_docs)] // documentation missing in model
58    Deleting,
59    #[allow(missing_docs)] // documentation missing in model
60    Failed,
61    #[allow(missing_docs)] // documentation missing in model
62    Failing,
63    #[allow(missing_docs)] // documentation missing in model
64    PausedOnFailure,
65    #[allow(missing_docs)] // documentation missing in model
66    Pending,
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 ReplicationJobState {
72    fn from(s: &str) -> Self {
73        match s {
74            "ACTIVE" => ReplicationJobState::Active,
75            "COMPLETED" => ReplicationJobState::Completed,
76            "DELETED" => ReplicationJobState::Deleted,
77            "DELETING" => ReplicationJobState::Deleting,
78            "FAILED" => ReplicationJobState::Failed,
79            "FAILING" => ReplicationJobState::Failing,
80            "PAUSED_ON_FAILURE" => ReplicationJobState::PausedOnFailure,
81            "PENDING" => ReplicationJobState::Pending,
82            other => ReplicationJobState::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
83        }
84    }
85}
86impl ::std::str::FromStr for ReplicationJobState {
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(ReplicationJobState::from(s))
91    }
92}
93impl ReplicationJobState {
94    /// Returns the `&str` value of the enum member.
95    pub fn as_str(&self) -> &str {
96        match self {
97            ReplicationJobState::Active => "ACTIVE",
98            ReplicationJobState::Completed => "COMPLETED",
99            ReplicationJobState::Deleted => "DELETED",
100            ReplicationJobState::Deleting => "DELETING",
101            ReplicationJobState::Failed => "FAILED",
102            ReplicationJobState::Failing => "FAILING",
103            ReplicationJobState::PausedOnFailure => "PAUSED_ON_FAILURE",
104            ReplicationJobState::Pending => "PENDING",
105            ReplicationJobState::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            "ACTIVE",
112            "COMPLETED",
113            "DELETED",
114            "DELETING",
115            "FAILED",
116            "FAILING",
117            "PAUSED_ON_FAILURE",
118            "PENDING",
119        ]
120    }
121}
122impl ::std::convert::AsRef<str> for ReplicationJobState {
123    fn as_ref(&self) -> &str {
124        self.as_str()
125    }
126}
127impl ReplicationJobState {
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 ReplicationJobState {
140    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
141        match self {
142            ReplicationJobState::Active => write!(f, "ACTIVE"),
143            ReplicationJobState::Completed => write!(f, "COMPLETED"),
144            ReplicationJobState::Deleted => write!(f, "DELETED"),
145            ReplicationJobState::Deleting => write!(f, "DELETING"),
146            ReplicationJobState::Failed => write!(f, "FAILED"),
147            ReplicationJobState::Failing => write!(f, "FAILING"),
148            ReplicationJobState::PausedOnFailure => write!(f, "PAUSED_ON_FAILURE"),
149            ReplicationJobState::Pending => write!(f, "PENDING"),
150            ReplicationJobState::Unknown(value) => write!(f, "{}", value),
151        }
152    }
153}