diff options
author | Florian Klink <flokli@flokli.de> | 2023-07-18T18·34+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-07-21T18·04+0000 |
commit | 42dc18353d99453bc0f83492f9f5bc4796f4cc4c (patch) | |
tree | 4f3d2d90106cea54f37620de082c6eb12754a658 /tvix/store/src/proto | |
parent | 5364fcb12708667a2dc698a689d00d70d1bf75af (diff) |
feat(tvix/nix-compat): have StorePath accept bytes r/6433
The primary constructor for this is now from_bytes, from_string is simply calling .as_bytes() on the string, passing it along. The InvalidName error now contains a Vec<u8>, to encode the invalid name (which might not be a string anymore). from_absolute_path now accepts a &[u8] (even though we might want to make this a OSString of some sort). StorePath::validate_name has been degraded to a pub(crate) function. It's still used in src/derivation, even though it probably shouldn't at all - that cleanup is left for cl/8412 though. Change-Id: I6b4e62a6fa5c4bec13b535279e73444f0b83ad35 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8973 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/store/src/proto')
-rw-r--r-- | tvix/store/src/proto/mod.rs | 3 | ||||
-rw-r--r-- | tvix/store/src/proto/tests/pathinfo.rs | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index 4db0b9731edc..7e69726632ce 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -1,5 +1,6 @@ #![allow(clippy::derive_partial_eq_without_eq)] // https://github.com/hyperium/tonic/issues/1056 +use std::str::FromStr; use std::{collections::HashSet, iter::Peekable}; use thiserror::Error; @@ -97,7 +98,7 @@ fn parse_node_name_root<E>( name: &str, err: fn(String, store_path::Error) -> E, ) -> Result<StorePath, E> { - match StorePath::from_string(name) { + match StorePath::from_str(name) { Ok(np) => Ok(np), Err(e) => Err(err(name.to_string(), e)), } diff --git a/tvix/store/src/proto/tests/pathinfo.rs b/tvix/store/src/proto/tests/pathinfo.rs index 57104a5fda19..bccec539f9f3 100644 --- a/tvix/store/src/proto/tests/pathinfo.rs +++ b/tvix/store/src/proto/tests/pathinfo.rs @@ -1,6 +1,7 @@ use crate::proto::{self, Node, PathInfo, ValidatePathInfoError}; use lazy_static::lazy_static; use nix_compat::store_path::{self, StorePath}; +use std::str::FromStr; use test_case::test_case; lazy_static! { @@ -46,7 +47,7 @@ fn validate_no_node( digest: DUMMY_DIGEST.to_vec(), size: 0, }, - Ok(StorePath::from_string(DUMMY_NAME).expect("must succeed")); + Ok(StorePath::from_str(DUMMY_NAME).expect("must succeed")); "ok" )] #[test_case( @@ -91,7 +92,7 @@ fn validate_directory( size: 0, executable: false, }, - Ok(StorePath::from_string(DUMMY_NAME).expect("must succeed")); + Ok(StorePath::from_str(DUMMY_NAME).expect("must succeed")); "ok" )] #[test_case( @@ -131,7 +132,7 @@ fn validate_file(t_file_node: proto::FileNode, t_result: Result<StorePath, Valid name: DUMMY_NAME.to_string(), ..Default::default() }, - Ok(StorePath::from_string(DUMMY_NAME).expect("must succeed")); + Ok(StorePath::from_str(DUMMY_NAME).expect("must succeed")); "ok" )] #[test_case( |