about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-02-20T05·12+0700
committerflokli <flokli@flokli.de>2024-02-20T05·29+0000
commit43570bae11ff5c5fac5c644785a7c372367826ba (patch)
tree0119a2f858c978a54e521d84bdc37963540b932d /tvix
parent98a17dbdf9f6756b5162d34eda17098918e991cf (diff)
refactor(tvix/store/proto): use bstr::ByteSlice r/7566
String::from_utf8_lossy simply discards invalid bytes, while bstr
replaces them with their replacement character.

Change-Id: Ib78ff36ca5faacc1ad60bc4ddde7b62773848c07
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10981
Tested-by: BuildkiteCI
Reviewed-by: Peter Kolloch <info@eigenvalue.net>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/Cargo.lock1
-rw-r--r--tvix/Cargo.nix4
-rw-r--r--tvix/store/Cargo.toml1
-rw-r--r--tvix/store/src/proto/mod.rs3
4 files changed, 8 insertions, 1 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock
index 9801ed4c0a..26c0a47ddd 100644
--- a/tvix/Cargo.lock
+++ b/tvix/Cargo.lock
@@ -3417,6 +3417,7 @@ dependencies = [
  "async-recursion",
  "async-stream",
  "blake3",
+ "bstr",
  "bytes",
  "clap",
  "count-write",
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index a39c8ef38d..f12d955061 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -10789,6 +10789,10 @@ rec {
             features = [ "rayon" "std" ];
           }
           {
+            name = "bstr";
+            packageId = "bstr";
+          }
+          {
             name = "bytes";
             packageId = "bytes";
           }
diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml
index 9065465af6..bf0d341360 100644
--- a/tvix/store/Cargo.toml
+++ b/tvix/store/Cargo.toml
@@ -7,6 +7,7 @@ edition = "2021"
 anyhow = "1.0.68"
 async-stream = "0.3.5"
 blake3 = { version = "1.3.1", features = ["rayon", "std"] }
+bstr = "1.6.0"
 bytes = "1.4.0"
 clap = { version = "4.0", features = ["derive", "env"] }
 count-write = "0.1.0"
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs
index 9c8e44cfb5..76178a7a77 100644
--- a/tvix/store/src/proto/mod.rs
+++ b/tvix/store/src/proto/mod.rs
@@ -1,4 +1,5 @@
 #![allow(clippy::derive_partial_eq_without_eq, non_snake_case)]
+use bstr::ByteSlice;
 use bytes::Bytes;
 use data_encoding::BASE64;
 // https://github.com/hyperium/tonic/issues/1056
@@ -41,7 +42,7 @@ pub enum ValidatePathInfoError {
     InvalidRootNode(ValidateNodeError),
 
     /// Invalid node name encountered. Root nodes in PathInfos have more strict name requirements
-    #[error("Failed to parse {} as StorePath: {1}", String::from_utf8_lossy(.0))]
+    #[error("Failed to parse {} as StorePath: {1}", .0.to_str_lossy())]
     InvalidNodeName(Vec<u8>, store_path::Error),
 
     /// The digest in narinfo.nar_sha256 has an invalid len.