fix(tvix/nix-compat): don't box CAHash::Text
Change-Id: I31df3909bc21c9038f9fb831879e60e541242819 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9853 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
fdc2e90ef2
commit
99a61def17
3 changed files with 9 additions and 14 deletions
|
|
@ -19,17 +19,17 @@ use super::from_algo_and_digest;
|
|||
/// - "digest". The digest itself.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum CAHash {
|
||||
Flat(NixHash), // "fixed flat"
|
||||
Nar(NixHash), // "fixed recursive"
|
||||
Text(Box<[u8; 32]>), // "text", only supports sha256
|
||||
Flat(NixHash), // "fixed flat"
|
||||
Nar(NixHash), // "fixed recursive"
|
||||
Text([u8; 32]), // "text", only supports sha256
|
||||
}
|
||||
|
||||
impl CAHash {
|
||||
pub fn digest(&self) -> Cow<NixHash> {
|
||||
match self {
|
||||
CAHash::Nar(ref digest) => Cow::Borrowed(digest),
|
||||
CAHash::Text(ref digest) => Cow::Owned(NixHash::Sha256(*digest.clone())),
|
||||
match *self {
|
||||
CAHash::Flat(ref digest) => Cow::Borrowed(digest),
|
||||
CAHash::Nar(ref digest) => Cow::Borrowed(digest),
|
||||
CAHash::Text(digest) => Cow::Owned(NixHash::Sha256(digest)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue