about summary refs log tree commit diff
path: root/tvix/store/src/proto/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/proto/mod.rs')
-rw-r--r--tvix/store/src/proto/mod.rs47
1 files changed, 26 insertions, 21 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs
index a09839c8bdf9..b45e6fda46fe 100644
--- a/tvix/store/src/proto/mod.rs
+++ b/tvix/store/src/proto/mod.rs
@@ -260,24 +260,19 @@ impl TryFrom<&nar_info::Ca> for nix_compat::nixhash::CAHash {
 
     fn try_from(value: &nar_info::Ca) -> Result<Self, Self::Error> {
         Ok(match value.r#type {
-            typ if typ == nar_info::ca::Hash::FlatMd5 as i32 => {
-                Self::Flat(NixHash::Md5(value.digest[..].try_into().map_err(|_| {
-                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatMd5")
-                })?))
-            }
-            typ if typ == nar_info::ca::Hash::FlatSha1 as i32 => {
-                Self::Flat(NixHash::Sha1(value.digest[..].try_into().map_err(
-                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha1"),
+            typ if typ == nar_info::ca::Hash::NarSha256 as i32 => {
+                Self::Nar(NixHash::Sha256(value.digest[..].try_into().map_err(
+                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha256"),
                 )?))
             }
-            typ if typ == nar_info::ca::Hash::FlatSha256 as i32 => {
-                Self::Flat(NixHash::Sha256(value.digest[..].try_into().map_err(
-                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha256"),
+            typ if typ == nar_info::ca::Hash::NarSha1 as i32 => {
+                Self::Nar(NixHash::Sha1(value.digest[..].try_into().map_err(
+                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha1"),
                 )?))
             }
-            typ if typ == nar_info::ca::Hash::FlatSha512 as i32 => Self::Flat(NixHash::Sha512(
+            typ if typ == nar_info::ca::Hash::NarSha512 as i32 => Self::Nar(NixHash::Sha512(
                 Box::new(value.digest[..].try_into().map_err(|_| {
-                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha512")
+                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512")
                 })?),
             )),
             typ if typ == nar_info::ca::Hash::NarMd5 as i32 => {
@@ -285,19 +280,29 @@ impl TryFrom<&nar_info::Ca> for nix_compat::nixhash::CAHash {
                     ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarMd5")
                 })?))
             }
-            typ if typ == nar_info::ca::Hash::NarSha1 as i32 => {
-                Self::Nar(NixHash::Sha1(value.digest[..].try_into().map_err(
-                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha1"),
+            typ if typ == nar_info::ca::Hash::TextSha256 as i32 => {
+                Self::Text(value.digest[..].try_into().map_err(|_| {
+                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "TextSha256")
+                })?)
+            }
+            typ if typ == nar_info::ca::Hash::FlatSha1 as i32 => {
+                Self::Flat(NixHash::Sha1(value.digest[..].try_into().map_err(
+                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha1"),
                 )?))
             }
-            typ if typ == nar_info::ca::Hash::NarSha256 as i32 => {
-                Self::Nar(NixHash::Sha256(value.digest[..].try_into().map_err(
-                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha256"),
+            typ if typ == nar_info::ca::Hash::FlatMd5 as i32 => {
+                Self::Flat(NixHash::Md5(value.digest[..].try_into().map_err(|_| {
+                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatMd5")
+                })?))
+            }
+            typ if typ == nar_info::ca::Hash::FlatSha256 as i32 => {
+                Self::Flat(NixHash::Sha256(value.digest[..].try_into().map_err(
+                    |_| ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha256"),
                 )?))
             }
-            typ if typ == nar_info::ca::Hash::NarSha512 as i32 => Self::Nar(NixHash::Sha512(
+            typ if typ == nar_info::ca::Hash::FlatSha512 as i32 => Self::Flat(NixHash::Sha512(
                 Box::new(value.digest[..].try_into().map_err(|_| {
-                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "NarSha512")
+                    ConvertCAError::InvalidReferenceDigestLen(value.digest.len(), "FlatSha512")
                 })?),
             )),
             typ => return Err(ConvertCAError::UnknownHashType(typ)),