Skip to main content

aws_s3_transfer/model/
_checksum_algorithm.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When matching `ChecksumAlgorithm`, 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 ChecksumAlgorithm {
31    #[allow(missing_docs)] // documentation missing in model
32    Crc32,
33    #[allow(missing_docs)] // documentation missing in model
34    Crc32C,
35    #[allow(missing_docs)] // documentation missing in model
36    Crc64Nvme,
37    #[allow(missing_docs)] // documentation missing in model
38    Md5,
39    #[allow(missing_docs)] // documentation missing in model
40    Sha1,
41    #[allow(missing_docs)] // documentation missing in model
42    Sha256,
43    #[allow(missing_docs)] // documentation missing in model
44    Sha512,
45    #[allow(missing_docs)] // documentation missing in model
46    Xxhash128,
47    #[allow(missing_docs)] // documentation missing in model
48    Xxhash3,
49    #[allow(missing_docs)] // documentation missing in model
50    Xxhash64,
51    /// `Unknown` contains new variants that have been added since this code was generated.
52    #[deprecated(
53        note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants."
54    )]
55    Unknown(crate::model::sealed_enum_unknown::UnknownVariantValue),
56}
57impl ::std::convert::From<&str> for ChecksumAlgorithm {
58    fn from(s: &str) -> Self {
59        match s {
60            "CRC32" => ChecksumAlgorithm::Crc32,
61            "CRC32C" => ChecksumAlgorithm::Crc32C,
62            "CRC64NVME" => ChecksumAlgorithm::Crc64Nvme,
63            "MD5" => ChecksumAlgorithm::Md5,
64            "SHA1" => ChecksumAlgorithm::Sha1,
65            "SHA256" => ChecksumAlgorithm::Sha256,
66            "SHA512" => ChecksumAlgorithm::Sha512,
67            "XXHASH128" => ChecksumAlgorithm::Xxhash128,
68            "XXHASH3" => ChecksumAlgorithm::Xxhash3,
69            "XXHASH64" => ChecksumAlgorithm::Xxhash64,
70            other => ChecksumAlgorithm::Unknown(
71                crate::model::sealed_enum_unknown::UnknownVariantValue(other.to_owned()),
72            ),
73        }
74    }
75}
76impl ::std::str::FromStr for ChecksumAlgorithm {
77    type Err = ::std::convert::Infallible;
78
79    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
80        ::std::result::Result::Ok(ChecksumAlgorithm::from(s))
81    }
82}
83impl ChecksumAlgorithm {
84    /// Returns the `&str` value of the enum member.
85    pub fn as_str(&self) -> &str {
86        match self {
87            ChecksumAlgorithm::Crc32 => "CRC32",
88            ChecksumAlgorithm::Crc32C => "CRC32C",
89            ChecksumAlgorithm::Crc64Nvme => "CRC64NVME",
90            ChecksumAlgorithm::Md5 => "MD5",
91            ChecksumAlgorithm::Sha1 => "SHA1",
92            ChecksumAlgorithm::Sha256 => "SHA256",
93            ChecksumAlgorithm::Sha512 => "SHA512",
94            ChecksumAlgorithm::Xxhash128 => "XXHASH128",
95            ChecksumAlgorithm::Xxhash3 => "XXHASH3",
96            ChecksumAlgorithm::Xxhash64 => "XXHASH64",
97            ChecksumAlgorithm::Unknown(value) => value.as_str(),
98        }
99    }
100    /// Returns all the `&str` representations of the enum members.
101    pub const fn values() -> &'static [&'static str] {
102        &[
103            "CRC32",
104            "CRC32C",
105            "CRC64NVME",
106            "MD5",
107            "SHA1",
108            "SHA256",
109            "SHA512",
110            "XXHASH128",
111            "XXHASH3",
112            "XXHASH64",
113        ]
114    }
115}
116impl ::std::convert::AsRef<str> for ChecksumAlgorithm {
117    fn as_ref(&self) -> &str {
118        self.as_str()
119    }
120}
121impl ChecksumAlgorithm {
122    /// Parses the enum value while disallowing unknown variants.
123    ///
124    /// Unknown variants will result in an error.
125    pub fn try_parse(
126        value: &str,
127    ) -> ::std::result::Result<Self, crate::model::error::UnknownVariantError> {
128        match Self::from(value) {
129            #[allow(deprecated)]
130            Self::Unknown(_) => {
131                ::std::result::Result::Err(crate::model::error::UnknownVariantError::new(value))
132            }
133            known => Ok(known),
134        }
135    }
136}
137impl ::std::fmt::Display for ChecksumAlgorithm {
138    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
139        match self {
140            ChecksumAlgorithm::Crc32 => write!(f, "CRC32"),
141            ChecksumAlgorithm::Crc32C => write!(f, "CRC32C"),
142            ChecksumAlgorithm::Crc64Nvme => write!(f, "CRC64NVME"),
143            ChecksumAlgorithm::Md5 => write!(f, "MD5"),
144            ChecksumAlgorithm::Sha1 => write!(f, "SHA1"),
145            ChecksumAlgorithm::Sha256 => write!(f, "SHA256"),
146            ChecksumAlgorithm::Sha512 => write!(f, "SHA512"),
147            ChecksumAlgorithm::Xxhash128 => write!(f, "XXHASH128"),
148            ChecksumAlgorithm::Xxhash3 => write!(f, "XXHASH3"),
149            ChecksumAlgorithm::Xxhash64 => write!(f, "XXHASH64"),
150            ChecksumAlgorithm::Unknown(value) => write!(f, "{value}"),
151        }
152    }
153}