1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/// Algorithm used for hashing the data.
#[derive(Debug, PartialEq)]
pub enum HashType {
  /// [BLAKE2b](https://blake2.net/) hashing algorithm.
  BLAKE2b,
  /// [Ed25519](https://ed25519.cr.yp.to/) hashing algorithm.
  Ed25519,
  /// No hashing used.
  None,
}

impl HashType {
  /// Returns true if the hash is `BLAKE2b`
  #[inline]
  pub fn is_blake2b(&self) -> bool {
    *self == HashType::BLAKE2b
  }

  /// Returns true if the hash is `Ed25519`
  #[inline]
  pub fn is_ed25519(&self) -> bool {
    *self == HashType::Ed25519
  }

  /// Returns true if no hash function was used.
  #[inline]
  pub fn is_none(&self) -> bool {
    *self == HashType::None
  }
}