hashes: Implement From<Hash> for String.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-27 12:22:11 +01:00
parent 357568813d
commit 42235c42fb

View file

@ -47,9 +47,9 @@ impl FromStr for Algo {
} }
} }
impl IntoAttributeValue for Algo { impl From<Algo> for String {
fn into_attribute_value(self) -> Option<String> { fn from(algo: Algo) -> String {
Some(String::from(match self { String::from(match algo {
Algo::Sha_1 => "sha-1", Algo::Sha_1 => "sha-1",
Algo::Sha_256 => "sha-256", Algo::Sha_256 => "sha-256",
Algo::Sha_512 => "sha-512", Algo::Sha_512 => "sha-512",
@ -57,8 +57,14 @@ impl IntoAttributeValue for Algo {
Algo::Sha3_512 => "sha3-512", Algo::Sha3_512 => "sha3-512",
Algo::Blake2b_256 => "blake2b-256", Algo::Blake2b_256 => "blake2b-256",
Algo::Blake2b_512 => "blake2b-512", Algo::Blake2b_512 => "blake2b-512",
Algo::Unknown(text) => return Some(text), Algo::Unknown(text) => return text,
})) })
}
}
impl IntoAttributeValue for Algo {
fn into_attribute_value(self) -> Option<String> {
Some(String::from(self))
} }
} }