From 0f7e4bec6671d6b91c62b2b82c699211f2000622 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 17 Jan 2023 12:39:25 +0100 Subject: feat(tvix/store): rename and expose StorePath::validate_name Change-Id: I8a16c214c7c644756d9d54187beba8c80ccfb39c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7853 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/store/src/store_path.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tvix/store') diff --git a/tvix/store/src/store_path.rs b/tvix/store/src/store_path.rs index 925a0b4ccff2..f437edb6b2d8 100644 --- a/tvix/store/src/store_path.rs +++ b/tvix/store/src/store_path.rs @@ -64,7 +64,7 @@ impl StorePath { return Err(ParseStorePathError::MissingDash()); } - StorePath::validate_characters(&s[ENCODED_DIGEST_SIZE + 2..])?; + StorePath::validate_name(&s[ENCODED_DIGEST_SIZE + 2..])?; Ok(StorePath { name: s[ENCODED_DIGEST_SIZE + 1..].to_string(), @@ -87,7 +87,8 @@ impl StorePath { format!("{}/{}", STORE_DIR, self) } - fn validate_characters(s: &str) -> Result<(), ParseStorePathError> { + /// Checks a given &str to match the restrictions for store path names. + pub fn validate_name(s: &str) -> Result<(), ParseStorePathError> { for c in s.chars() { if c.is_ascii_alphanumeric() || c == '-' -- cgit 1.4.1