Skip to main content

aws_sdk_acmpca/types/
_signing_algorithm.rs

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