diff options
author | edef <edef@edef.eu> | 2023-10-27T12·07+0000 |
---|---|---|
committer | edef <edef@edef.eu> | 2023-10-27T13·56+0000 |
commit | c19c6c23cb2a36279ee147d335ffbe506b0f485b (patch) | |
tree | aa527028dd580a10bea86efc14014138845f7804 /tvix/nix-compat/src/store_path/mod.rs | |
parent | b994f692d3c02a858eacfece9e6a7d6990f46539 (diff) |
feat(nix-compat/store_path): validate_name takes AsRef<[u8]> r/6891
Change-Id: I8819e2a7b63008a68f4f82035a08b960ac480dc3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9858 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat/src/store_path/mod.rs')
-rw-r--r-- | tvix/nix-compat/src/store_path/mod.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs index 56bf639f2129..8c5f6fd5c222 100644 --- a/tvix/nix-compat/src/store_path/mod.rs +++ b/tvix/nix-compat/src/store_path/mod.rs @@ -177,7 +177,9 @@ impl StorePath { /// Checks a given &[u8] to match the restrictions for [StorePath::name], and /// returns the name as string if successful. -pub(crate) fn validate_name(s: &[u8]) -> Result<&str, Error> { +pub(crate) fn validate_name(s: &(impl AsRef<[u8]> + ?Sized)) -> Result<&str, Error> { + let s = s.as_ref(); + // Empty or excessively long names are not allowed. if s.is_empty() || s.len() > 211 { return Err(Error::InvalidLength()); |