Skip to main content

aws_sdk_accessanalyzer/types/
_kms_grant_operation.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `KmsGrantOperation`, 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 kmsgrantoperation = unimplemented!();
14/// match kmsgrantoperation {
15///     KmsGrantOperation::CreateGrant => { /* ... */ },
16///     KmsGrantOperation::Decrypt => { /* ... */ },
17///     KmsGrantOperation::DescribeKey => { /* ... */ },
18///     KmsGrantOperation::Encrypt => { /* ... */ },
19///     KmsGrantOperation::GenerateDataKey => { /* ... */ },
20///     KmsGrantOperation::GenerateDataKeyPair => { /* ... */ },
21///     KmsGrantOperation::GenerateDataKeyPairWithoutPlaintext => { /* ... */ },
22///     KmsGrantOperation::GenerateDataKeyWithoutPlaintext => { /* ... */ },
23///     KmsGrantOperation::GetPublicKey => { /* ... */ },
24///     KmsGrantOperation::ReencryptFrom => { /* ... */ },
25///     KmsGrantOperation::ReencryptTo => { /* ... */ },
26///     KmsGrantOperation::RetireGrant => { /* ... */ },
27///     KmsGrantOperation::Sign => { /* ... */ },
28///     KmsGrantOperation::Verify => { /* ... */ },
29///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
30///     _ => { /* ... */ },
31/// }
32/// ```
33/// The above code demonstrates that when `kmsgrantoperation` represents
34/// `NewFeature`, the execution path will lead to the second last match arm,
35/// even though the enum does not contain a variant `KmsGrantOperation::NewFeature`
36/// in the current version of SDK. The reason is that the variable `other`,
37/// created by the `@` operator, is bound to
38/// `KmsGrantOperation::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
39/// and calling `as_str` on it yields `"NewFeature"`.
40/// This match expression is forward-compatible when executed with a newer
41/// version of SDK where the variant `KmsGrantOperation::NewFeature` is defined.
42/// Specifically, when `kmsgrantoperation` represents `NewFeature`,
43/// the execution path will hit the second last match arm as before by virtue of
44/// calling `as_str` on `KmsGrantOperation::NewFeature` also yielding `"NewFeature"`.
45///
46/// Explicitly matching on the `Unknown` variant should
47/// be avoided for two reasons:
48/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
49/// - It might inadvertently shadow other intended match arms.
50///
51#[allow(missing_docs)] // documentation missing in model
52#[non_exhaustive]
53#[derive(
54    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
55)]
56pub enum KmsGrantOperation {
57    #[allow(missing_docs)] // documentation missing in model
58    CreateGrant,
59    #[allow(missing_docs)] // documentation missing in model
60    Decrypt,
61    #[allow(missing_docs)] // documentation missing in model
62    DescribeKey,
63    #[allow(missing_docs)] // documentation missing in model
64    Encrypt,
65    #[allow(missing_docs)] // documentation missing in model
66    GenerateDataKey,
67    #[allow(missing_docs)] // documentation missing in model
68    GenerateDataKeyPair,
69    #[allow(missing_docs)] // documentation missing in model
70    GenerateDataKeyPairWithoutPlaintext,
71    #[allow(missing_docs)] // documentation missing in model
72    GenerateDataKeyWithoutPlaintext,
73    #[allow(missing_docs)] // documentation missing in model
74    GetPublicKey,
75    #[allow(missing_docs)] // documentation missing in model
76    ReencryptFrom,
77    #[allow(missing_docs)] // documentation missing in model
78    ReencryptTo,
79    #[allow(missing_docs)] // documentation missing in model
80    RetireGrant,
81    #[allow(missing_docs)] // documentation missing in model
82    Sign,
83    #[allow(missing_docs)] // documentation missing in model
84    Verify,
85    /// `Unknown` contains new variants that have been added since this code was generated.
86    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
87    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
88}
89impl ::std::convert::From<&str> for KmsGrantOperation {
90    fn from(s: &str) -> Self {
91        match s {
92            "CreateGrant" => KmsGrantOperation::CreateGrant,
93            "Decrypt" => KmsGrantOperation::Decrypt,
94            "DescribeKey" => KmsGrantOperation::DescribeKey,
95            "Encrypt" => KmsGrantOperation::Encrypt,
96            "GenerateDataKey" => KmsGrantOperation::GenerateDataKey,
97            "GenerateDataKeyPair" => KmsGrantOperation::GenerateDataKeyPair,
98            "GenerateDataKeyPairWithoutPlaintext" => KmsGrantOperation::GenerateDataKeyPairWithoutPlaintext,
99            "GenerateDataKeyWithoutPlaintext" => KmsGrantOperation::GenerateDataKeyWithoutPlaintext,
100            "GetPublicKey" => KmsGrantOperation::GetPublicKey,
101            "ReEncryptFrom" => KmsGrantOperation::ReencryptFrom,
102            "ReEncryptTo" => KmsGrantOperation::ReencryptTo,
103            "RetireGrant" => KmsGrantOperation::RetireGrant,
104            "Sign" => KmsGrantOperation::Sign,
105            "Verify" => KmsGrantOperation::Verify,
106            other => KmsGrantOperation::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
107        }
108    }
109}
110impl ::std::str::FromStr for KmsGrantOperation {
111    type Err = ::std::convert::Infallible;
112
113    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
114        ::std::result::Result::Ok(KmsGrantOperation::from(s))
115    }
116}
117impl KmsGrantOperation {
118    /// Returns the `&str` value of the enum member.
119    pub fn as_str(&self) -> &str {
120        match self {
121            KmsGrantOperation::CreateGrant => "CreateGrant",
122            KmsGrantOperation::Decrypt => "Decrypt",
123            KmsGrantOperation::DescribeKey => "DescribeKey",
124            KmsGrantOperation::Encrypt => "Encrypt",
125            KmsGrantOperation::GenerateDataKey => "GenerateDataKey",
126            KmsGrantOperation::GenerateDataKeyPair => "GenerateDataKeyPair",
127            KmsGrantOperation::GenerateDataKeyPairWithoutPlaintext => "GenerateDataKeyPairWithoutPlaintext",
128            KmsGrantOperation::GenerateDataKeyWithoutPlaintext => "GenerateDataKeyWithoutPlaintext",
129            KmsGrantOperation::GetPublicKey => "GetPublicKey",
130            KmsGrantOperation::ReencryptFrom => "ReEncryptFrom",
131            KmsGrantOperation::ReencryptTo => "ReEncryptTo",
132            KmsGrantOperation::RetireGrant => "RetireGrant",
133            KmsGrantOperation::Sign => "Sign",
134            KmsGrantOperation::Verify => "Verify",
135            KmsGrantOperation::Unknown(value) => value.as_str(),
136        }
137    }
138    /// Returns all the `&str` representations of the enum members.
139    pub const fn values() -> &'static [&'static str] {
140        &[
141            "CreateGrant",
142            "Decrypt",
143            "DescribeKey",
144            "Encrypt",
145            "GenerateDataKey",
146            "GenerateDataKeyPair",
147            "GenerateDataKeyPairWithoutPlaintext",
148            "GenerateDataKeyWithoutPlaintext",
149            "GetPublicKey",
150            "ReEncryptFrom",
151            "ReEncryptTo",
152            "RetireGrant",
153            "Sign",
154            "Verify",
155        ]
156    }
157}
158impl ::std::convert::AsRef<str> for KmsGrantOperation {
159    fn as_ref(&self) -> &str {
160        self.as_str()
161    }
162}
163impl KmsGrantOperation {
164    /// Parses the enum value while disallowing unknown variants.
165    ///
166    /// Unknown variants will result in an error.
167    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
168        match Self::from(value) {
169            #[allow(deprecated)]
170            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
171            known => Ok(known),
172        }
173    }
174}
175impl ::std::fmt::Display for KmsGrantOperation {
176    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
177        match self {
178            KmsGrantOperation::CreateGrant => write!(f, "CreateGrant"),
179            KmsGrantOperation::Decrypt => write!(f, "Decrypt"),
180            KmsGrantOperation::DescribeKey => write!(f, "DescribeKey"),
181            KmsGrantOperation::Encrypt => write!(f, "Encrypt"),
182            KmsGrantOperation::GenerateDataKey => write!(f, "GenerateDataKey"),
183            KmsGrantOperation::GenerateDataKeyPair => write!(f, "GenerateDataKeyPair"),
184            KmsGrantOperation::GenerateDataKeyPairWithoutPlaintext => write!(f, "GenerateDataKeyPairWithoutPlaintext"),
185            KmsGrantOperation::GenerateDataKeyWithoutPlaintext => write!(f, "GenerateDataKeyWithoutPlaintext"),
186            KmsGrantOperation::GetPublicKey => write!(f, "GetPublicKey"),
187            KmsGrantOperation::ReencryptFrom => write!(f, "ReEncryptFrom"),
188            KmsGrantOperation::ReencryptTo => write!(f, "ReEncryptTo"),
189            KmsGrantOperation::RetireGrant => write!(f, "RetireGrant"),
190            KmsGrantOperation::Sign => write!(f, "Sign"),
191            KmsGrantOperation::Verify => write!(f, "Verify"),
192            KmsGrantOperation::Unknown(value) => write!(f, "{value}"),
193        }
194    }
195}