about summary refs log tree commit diff
path: root/tvix/castore/src/digests.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-03T12·40+0200
committerclbot <clbot@tvl.fyi>2024-03-03T15·18+0000
commit8383e9e02e1f762013a652e9a842493a1be5bb60 (patch)
treefbc79f6f10f4b3abf17722701b9a7bcc8d7c3c82 /tvix/castore/src/digests.rs
parent9a7246ea1dac200648976be4558e29c3e9aa7eb7 (diff)
feat(tvix/castore/digests): impl From digest::Output<_> for B3Digest r/7640
This allows calling .into() to get a B3Digest.

Change-Id: I6e63b496413cd00d84acfcd15c7de0f64c79721f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11086
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/digests.rs')
-rw-r--r--tvix/castore/src/digests.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/tvix/castore/src/digests.rs b/tvix/castore/src/digests.rs
index 137ed2669a8f..8a1938c1b649 100644
--- a/tvix/castore/src/digests.rs
+++ b/tvix/castore/src/digests.rs
@@ -26,6 +26,13 @@ impl From<B3Digest> for bytes::Bytes {
     }
 }
 
+impl From<digest::Output<blake3::Hasher>> for B3Digest {
+    fn from(value: digest::Output<blake3::Hasher>) -> Self {
+        let v = Into::<[u8; B3_LEN]>::into(value);
+        Self(Bytes::copy_from_slice(&v))
+    }
+}
+
 impl TryFrom<Vec<u8>> for B3Digest {
     type Error = Error;