about summary refs log tree commit diff
path: root/tvix/castore/src/fixtures.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-08-15T23·24+0300
committerclbot <clbot@tvl.fyi>2024-08-17T09·46+0000
commit8ea7d2b60eb4052d934820078c31ff25786376a4 (patch)
treeda04e2f8f655f31c07a03d13ccbb1e0a7ed8e159 /tvix/castore/src/fixtures.rs
parent49b173786cba575dbeb9d28fa7a62275d45ce41a (diff)
refactor(tvix/castore): drop {Directory,File,Symlink}Node r/8505
Add a `SymlinkTarget` type to represent validated symlink targets.
With this, no invalid states are representable, so we can make `Node` be
just an enum of all three kind of types, and allow access to these
fields directly.

Change-Id: I20bdd480c8d5e64a827649f303c97023b7e390f2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12216
Reviewed-by: benjaminedwardwebb <benjaminedwardwebb@gmail.com>
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src/fixtures.rs')
-rw-r--r--tvix/castore/src/fixtures.rs78
1 files changed, 38 insertions, 40 deletions
diff --git a/tvix/castore/src/fixtures.rs b/tvix/castore/src/fixtures.rs
index b57540d177e2..ddeacaf1d5b9 100644
--- a/tvix/castore/src/fixtures.rs
+++ b/tvix/castore/src/fixtures.rs
@@ -1,6 +1,4 @@
-use crate::{
-    B3Digest, {Directory, DirectoryNode, FileNode, Node, SymlinkNode},
-};
+use crate::{B3Digest, Directory, Node};
 use lazy_static::lazy_static;
 
 pub const HELLOWORLD_BLOB_CONTENTS: &[u8] = b"Hello World!";
@@ -37,11 +35,11 @@ lazy_static! {
         let mut dir = Directory::new();
         dir.add(
             ".keep".into(),
-            Node::File(FileNode::new(
-                EMPTY_BLOB_DIGEST.clone(),
-                0,
-                false
-            ))).unwrap();
+            Node::File{
+                digest: EMPTY_BLOB_DIGEST.clone(),
+                size: 0,
+                executable: false
+            }).unwrap();
 
         dir
     };
@@ -49,22 +47,22 @@ lazy_static! {
         let mut dir = Directory::new();
         dir.add(
             "keep".into(),
-            Node::Directory(DirectoryNode::new(
-                DIRECTORY_WITH_KEEP.digest(),
-                DIRECTORY_WITH_KEEP.size()
-            ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_WITH_KEEP.digest(),
+                size: DIRECTORY_WITH_KEEP.size()
+            }).unwrap();
         dir.add(
             ".keep".into(),
-            Node::File(FileNode::new(
-            EMPTY_BLOB_DIGEST.clone(),
-            0,
-            false
-        ))).unwrap();
+            Node::File{
+                digest: EMPTY_BLOB_DIGEST.clone(),
+                size: 0,
+                executable: false
+            }).unwrap();
         dir.add(
             "aa".into(),
-            Node::Symlink(SymlinkNode::new(
-                b"/nix/store/somewhereelse".to_vec().into()
-            ).unwrap())).unwrap();
+            Node::Symlink{
+                target: "/nix/store/somewhereelse".try_into().unwrap()
+            }).unwrap();
 
         dir
     };
@@ -73,10 +71,10 @@ lazy_static! {
         let mut dir = Directory::new();
         dir.add(
             "a".into(),
-            Node::Directory(DirectoryNode::new(
-                DIRECTORY_A.digest(),
-                DIRECTORY_A.size(),
-            ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_A.digest(),
+                size: DIRECTORY_A.size(),
+            }).unwrap();
 
         dir
     };
@@ -84,16 +82,16 @@ lazy_static! {
         let mut dir = Directory::new();
         dir.add(
             "a".into(),
-            Node::Directory(DirectoryNode::new(
-                DIRECTORY_A.digest(),
-                DIRECTORY_A.size(),
-            ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_A.digest(),
+                size: DIRECTORY_A.size(),
+            }).unwrap();
         dir.add(
             "a'".into(),
-            Node::Directory(DirectoryNode::new(
-                    DIRECTORY_A.digest(),
-                    DIRECTORY_A.size(),
-        ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_A.digest(),
+                size: DIRECTORY_A.size(),
+        }).unwrap();
 
         dir
     };
@@ -101,16 +99,16 @@ lazy_static! {
         let mut dir = Directory::new();
         dir.add(
             "a".into(),
-            Node::Directory(DirectoryNode::new(
-                DIRECTORY_A.digest(),
-                DIRECTORY_A.size(),
-            ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_A.digest(),
+                size: DIRECTORY_A.size(),
+            }).unwrap();
         dir.add(
             "b".into(),
-            Node::Directory(DirectoryNode::new(
-                DIRECTORY_B.digest(),
-                DIRECTORY_B.size(),
-            ))).unwrap();
+            Node::Directory{
+                digest: DIRECTORY_B.digest(),
+                size: DIRECTORY_B.size(),
+            }).unwrap();
 
         dir
     };