aws_sdk_workspaces/types/
_deletable_certificate_based_auth_property.rs

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