Skip to content

Commit

Permalink
digest: Add Hash derives
Browse files Browse the repository at this point in the history
I hit this when porting ocidir-rs; previously strings
were hashable and it clearly makes sense for digests to be.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Sep 12, 2024
1 parent 610da48 commit 3996967
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/image/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::str::FromStr;
/// standards. Other digest algorithms may be added
/// in the future, so this structure is marked as non-exhaustive.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum DigestAlgorithm {
/// The SHA-256 algorithm.
Sha256,
Expand Down Expand Up @@ -95,7 +95,7 @@ fn char_is_encoded(c: char) -> bool {
/// # }
/// ```

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Digest {
/// The algorithm
algorithm: DigestAlgorithm,
Expand Down Expand Up @@ -202,7 +202,7 @@ impl FromStr for Digest {
}

/// A SHA-256 digest, guaranteed to be 64 lowercase hexadecimal ASCII characters.
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Sha256Digest {
digest: Box<str>,
}
Expand Down

0 comments on commit 3996967

Please sign in to comment.