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