aws_sdk_ec2/types/
_verified_access_endpoint_status_code.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `VerifiedAccessEndpointStatusCode`, 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 verifiedaccessendpointstatuscode = unimplemented!();
14/// match verifiedaccessendpointstatuscode {
15///     VerifiedAccessEndpointStatusCode::Active => { /* ... */ },
16///     VerifiedAccessEndpointStatusCode::Deleted => { /* ... */ },
17///     VerifiedAccessEndpointStatusCode::Deleting => { /* ... */ },
18///     VerifiedAccessEndpointStatusCode::Pending => { /* ... */ },
19///     VerifiedAccessEndpointStatusCode::Updating => { /* ... */ },
20///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
21///     _ => { /* ... */ },
22/// }
23/// ```
24/// The above code demonstrates that when `verifiedaccessendpointstatuscode` represents
25/// `NewFeature`, the execution path will lead to the second last match arm,
26/// even though the enum does not contain a variant `VerifiedAccessEndpointStatusCode::NewFeature`
27/// in the current version of SDK. The reason is that the variable `other`,
28/// created by the `@` operator, is bound to
29/// `VerifiedAccessEndpointStatusCode::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 `VerifiedAccessEndpointStatusCode::NewFeature` is defined.
33/// Specifically, when `verifiedaccessendpointstatuscode` represents `NewFeature`,
34/// the execution path will hit the second last match arm as before by virtue of
35/// calling `as_str` on `VerifiedAccessEndpointStatusCode::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#[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 VerifiedAccessEndpointStatusCode {
48    #[allow(missing_docs)] // documentation missing in model
49    Active,
50    #[allow(missing_docs)] // documentation missing in model
51    Deleted,
52    #[allow(missing_docs)] // documentation missing in model
53    Deleting,
54    #[allow(missing_docs)] // documentation missing in model
55    Pending,
56    #[allow(missing_docs)] // documentation missing in model
57    Updating,
58    /// `Unknown` contains new variants that have been added since this code was generated.
59    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
60    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
61}
62impl ::std::convert::From<&str> for VerifiedAccessEndpointStatusCode {
63    fn from(s: &str) -> Self {
64        match s {
65            "active" => VerifiedAccessEndpointStatusCode::Active,
66            "deleted" => VerifiedAccessEndpointStatusCode::Deleted,
67            "deleting" => VerifiedAccessEndpointStatusCode::Deleting,
68            "pending" => VerifiedAccessEndpointStatusCode::Pending,
69            "updating" => VerifiedAccessEndpointStatusCode::Updating,
70            other => VerifiedAccessEndpointStatusCode::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
71        }
72    }
73}
74impl ::std::str::FromStr for VerifiedAccessEndpointStatusCode {
75    type Err = ::std::convert::Infallible;
76
77    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
78        ::std::result::Result::Ok(VerifiedAccessEndpointStatusCode::from(s))
79    }
80}
81impl VerifiedAccessEndpointStatusCode {
82    /// Returns the `&str` value of the enum member.
83    pub fn as_str(&self) -> &str {
84        match self {
85            VerifiedAccessEndpointStatusCode::Active => "active",
86            VerifiedAccessEndpointStatusCode::Deleted => "deleted",
87            VerifiedAccessEndpointStatusCode::Deleting => "deleting",
88            VerifiedAccessEndpointStatusCode::Pending => "pending",
89            VerifiedAccessEndpointStatusCode::Updating => "updating",
90            VerifiedAccessEndpointStatusCode::Unknown(value) => value.as_str(),
91        }
92    }
93    /// Returns all the `&str` representations of the enum members.
94    pub const fn values() -> &'static [&'static str] {
95        &["active", "deleted", "deleting", "pending", "updating"]
96    }
97}
98impl ::std::convert::AsRef<str> for VerifiedAccessEndpointStatusCode {
99    fn as_ref(&self) -> &str {
100        self.as_str()
101    }
102}
103impl VerifiedAccessEndpointStatusCode {
104    /// Parses the enum value while disallowing unknown variants.
105    ///
106    /// Unknown variants will result in an error.
107    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
108        match Self::from(value) {
109            #[allow(deprecated)]
110            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
111            known => Ok(known),
112        }
113    }
114}
115impl ::std::fmt::Display for VerifiedAccessEndpointStatusCode {
116    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
117        match self {
118            VerifiedAccessEndpointStatusCode::Active => write!(f, "active"),
119            VerifiedAccessEndpointStatusCode::Deleted => write!(f, "deleted"),
120            VerifiedAccessEndpointStatusCode::Deleting => write!(f, "deleting"),
121            VerifiedAccessEndpointStatusCode::Pending => write!(f, "pending"),
122            VerifiedAccessEndpointStatusCode::Updating => write!(f, "updating"),
123            VerifiedAccessEndpointStatusCode::Unknown(value) => write!(f, "{}", value),
124        }
125    }
126}