feat(tvix/nix-compat): Extract to_plain_hex_string
Towards https://b.tvl.fyi/issues/264 Change-Id: Ibde971bfb6baa97b5c678d84ce1941189bc59f6f Reviewed-on: https://cl.tvl.fyi/c/depot/+/10969 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: Peter Kolloch <info@eigenvalue.net> Tested-by: BuildkiteCI
This commit is contained in:
parent
df73d5f242
commit
46d89f899f
1 changed files with 6 additions and 5 deletions
|
@ -61,11 +61,7 @@ impl NixHash {
|
|||
/// Formats a [NixHash] in the Nix default hash format,
|
||||
/// which is the algo, followed by a colon, then the lower hex encoded digest.
|
||||
pub fn to_nix_hex_string(&self) -> String {
|
||||
format!(
|
||||
"{}:{}",
|
||||
self.algo(),
|
||||
HEXLOWER.encode(self.digest_as_bytes())
|
||||
)
|
||||
format!("{}:{}", self.algo(), self.to_plain_hex_string())
|
||||
}
|
||||
|
||||
/// Formats a [NixHash] in the format that's used inside CAHash,
|
||||
|
@ -77,6 +73,11 @@ impl NixHash {
|
|||
nixbase32::encode(self.digest_as_bytes())
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns the digest as a hex string -- without any algorithm prefix.
|
||||
pub fn to_plain_hex_string(&self) -> String {
|
||||
HEXLOWER.encode(self.digest_as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<(HashAlgo, &[u8])> for NixHash {
|
||||
|
|
Loading…
Reference in a new issue