about summary refs log tree commit diff
path: root/tvix/nix-compat/src/store_path/mod.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-22T18·38+0200
committerflokli <flokli@flokli.de>2023-11-22T20·11+0000
commit671206a63f89f0ca58f830eabae0d7c31f70a750 (patch)
tree8f579dd5547e7dd12028703735c2249b4cb58d61 /tvix/nix-compat/src/store_path/mod.rs
parenteb84898c177b5c4157efebc44c56459b9cf1ccf7 (diff)
refactor(tvix/nix-compat): move from_name_and_digest to StorePathRef r/7047
We can simply use .to_owned() on that thing afterwards if we want to
construct an owned StorePath.

Change-Id: I0f3e2e4434b99ee522f2a7dbfa391e13a987479c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10105
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/nix-compat/src/store_path/mod.rs')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index 93a1f0e889..830f75c36a 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -107,14 +107,6 @@ impl StorePath {
         }
     }
 
-    /// Construct a [StorePath] from a name and digest.
-    pub fn from_name_and_digest(name: String, digest: &[u8]) -> Result<StorePath, Error> {
-        Ok(Self {
-            name: validate_name(name.as_bytes())?.to_owned(),
-            digest: digest.try_into().map_err(|_| Error::InvalidLength)?,
-        })
-    }
-
     /// Decompose a string into a [StorePath] and a [PathBuf] containing the
     /// rest of the path, or an error.
     #[cfg(target_family = "unix")]
@@ -187,6 +179,14 @@ impl<'a> StorePathRef<'a> {
         }
     }
 
+    /// Construct a [StorePathRef] from a name and digest.
+    pub fn from_name_and_digest(name: &'a str, digest: &[u8]) -> Result<Self, Error> {
+        Ok(Self {
+            name: validate_name(name.as_bytes())?,
+            digest: digest.try_into().map_err(|_| Error::InvalidLength)?,
+        })
+    }
+
     /// Construct a [StorePathRef] by passing the `$digest-$name` string
     /// that comes after [STORE_DIR_WITH_SLASH].
     pub fn from_bytes(s: &'a [u8]) -> Result<Self, Error> {