diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-10-29 10:55:33 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-10-29 11:53:03 +0100 |
commit | 69e674c6ab89ab6755c4ce9069708cb19df0b9f5 (patch) | |
tree | 405e7beb10f363e49fc5cf465905f82cfc71634e /src/package/source.rs | |
parent | 5799e3220e81dca18eb85a52cee8af6ad1595e02 (diff) |
Implement Display for HashType, HashValue
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/package/source.rs')
-rw-r--r-- | src/package/source.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/package/source.rs b/src/package/source.rs index f98df68..bdac6ce 100644 --- a/src/package/source.rs +++ b/src/package/source.rs @@ -48,6 +48,17 @@ pub enum HashType { Sha512, } +impl std::fmt::Display for HashType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + match self { + HashType::Sha1 => write!(f, "sha1"), + HashType::Sha256 => write!(f, "sha256"), + HashType::Sha512 => write!(f, "sha512"), + } + } +} + + #[derive(Deserialize, Clone, Debug, Hash, Eq, PartialEq)] #[serde(transparent)] pub struct HashValue(String); @@ -59,4 +70,9 @@ impl From<String> for HashValue { } } +impl std::fmt::Display for HashValue { + fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { + self.0.fmt(f) + } +} |