aws_sdk_qconnect/types/
_quick_response_status.rs

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