Lowercase hex encoding, as used in Git refs and messages.
(&self)
| 123 | |
| 124 | /// Lowercase hex encoding, as used in Git refs and messages. |
| 125 | pub fn to_hex(&self) -> String { |
| 126 | self.as_bytes() |
| 127 | .iter() |
| 128 | .map(|byte| format!("{byte:02x}")) |
| 129 | .collect() |
| 130 | } |
| 131 | |
| 132 | /// Parse from lowercase hex (40 or 64 characters). |
| 133 | pub fn from_hex(hex: &str) -> Result<Self, BindingEncodeError> { |