Skip to main content

aws_s3_transfer/model/
_server_side_encryption.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When matching `ServerSideEncryption`, handle known variants and retain a wildcard
4/// arm for values introduced by S3 after this crate was generated.
5///
6/// To recognize a value that is not yet a named variant, use `as_str()`:
7///
8/// ```text
9/// match value {
10///     // Handle known variants here.
11///     other if other.as_str() == "NewFeature" => { /* ... */ },
12///     _ => { /* ... */ },
13/// }
14/// ```
15///
16/// This continues to recognize `"NewFeature"` if a future version of this crate
17/// adds a named variant for it. Avoid matching `Unknown` directly: its inner
18/// value is opaque, and that arm would no longer match the new named variant.
19#[allow(missing_docs)] // documentation missing in model
20#[non_exhaustive]
21#[derive(
22    ::std::clone::Clone,
23    ::std::cmp::Eq,
24    ::std::cmp::Ord,
25    ::std::cmp::PartialEq,
26    ::std::cmp::PartialOrd,
27    ::std::fmt::Debug,
28    ::std::hash::Hash,
29)]
30pub enum ServerSideEncryption {
31    #[allow(missing_docs)] // documentation missing in model
32    Aes256,
33    #[allow(missing_docs)] // documentation missing in model
34    AwsFsx,
35    #[allow(missing_docs)] // documentation missing in model
36    AwsKms,
37    #[allow(missing_docs)] // documentation missing in model
38    AwsKmsDsse,
39    /// `Unknown` contains new variants that have been added since this code was generated.
40    #[deprecated(
41        note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants."
42    )]
43    Unknown(crate::model::sealed_enum_unknown::UnknownVariantValue),
44}
45impl ::std::convert::From<&str> for ServerSideEncryption {
46    fn from(s: &str) -> Self {
47        match s {
48            "AES256" => ServerSideEncryption::Aes256,
49            "aws:fsx" => ServerSideEncryption::AwsFsx,
50            "aws:kms" => ServerSideEncryption::AwsKms,
51            "aws:kms:dsse" => ServerSideEncryption::AwsKmsDsse,
52            other => ServerSideEncryption::Unknown(
53                crate::model::sealed_enum_unknown::UnknownVariantValue(other.to_owned()),
54            ),
55        }
56    }
57}
58impl ::std::str::FromStr for ServerSideEncryption {
59    type Err = ::std::convert::Infallible;
60
61    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
62        ::std::result::Result::Ok(ServerSideEncryption::from(s))
63    }
64}
65impl ServerSideEncryption {
66    /// Returns the `&str` value of the enum member.
67    pub fn as_str(&self) -> &str {
68        match self {
69            ServerSideEncryption::Aes256 => "AES256",
70            ServerSideEncryption::AwsFsx => "aws:fsx",
71            ServerSideEncryption::AwsKms => "aws:kms",
72            ServerSideEncryption::AwsKmsDsse => "aws:kms:dsse",
73            ServerSideEncryption::Unknown(value) => value.as_str(),
74        }
75    }
76    /// Returns all the `&str` representations of the enum members.
77    pub const fn values() -> &'static [&'static str] {
78        &["AES256", "aws:fsx", "aws:kms", "aws:kms:dsse"]
79    }
80}
81impl ::std::convert::AsRef<str> for ServerSideEncryption {
82    fn as_ref(&self) -> &str {
83        self.as_str()
84    }
85}
86impl ServerSideEncryption {
87    /// Parses the enum value while disallowing unknown variants.
88    ///
89    /// Unknown variants will result in an error.
90    pub fn try_parse(
91        value: &str,
92    ) -> ::std::result::Result<Self, crate::model::error::UnknownVariantError> {
93        match Self::from(value) {
94            #[allow(deprecated)]
95            Self::Unknown(_) => {
96                ::std::result::Result::Err(crate::model::error::UnknownVariantError::new(value))
97            }
98            known => Ok(known),
99        }
100    }
101}
102impl ::std::fmt::Display for ServerSideEncryption {
103    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
104        match self {
105            ServerSideEncryption::Aes256 => write!(f, "AES256"),
106            ServerSideEncryption::AwsFsx => write!(f, "aws:fsx"),
107            ServerSideEncryption::AwsKms => write!(f, "aws:kms"),
108            ServerSideEncryption::AwsKmsDsse => write!(f, "aws:kms:dsse"),
109            ServerSideEncryption::Unknown(value) => write!(f, "{value}"),
110        }
111    }
112}