aws_s3_transfer/model/
_checksum_algorithm.rs1#[allow(missing_docs)] #[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)] Crc32,
33 #[allow(missing_docs)] Crc32C,
35 #[allow(missing_docs)] Crc64Nvme,
37 #[allow(missing_docs)] Md5,
39 #[allow(missing_docs)] Sha1,
41 #[allow(missing_docs)] Sha256,
43 #[allow(missing_docs)] Sha512,
45 #[allow(missing_docs)] Xxhash128,
47 #[allow(missing_docs)] Xxhash3,
49 #[allow(missing_docs)] Xxhash64,
51 #[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 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 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 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}