about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-10-15T23·04+0300
committerclbot <clbot@tvl.fyi>2024-10-16T00·16+0000
commitda9a6e5b782b9864b625135ebaaf4a12b9d0018e (patch)
tree51b8738cb008dcf0746c57e86deef75ae8edb3cf /tvix/eval/src
parenta833703dab8c4ef271cb8ae11df2ca5fa46c7343 (diff)
feat(tvix/eval/io): impl From<std::fs::FileType> for FileType r/8813
Change-Id: If92ddaf3b469c4635c234b193f8d7716e11887f6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12630
Tested-by: BuildkiteCI
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/io.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tvix/eval/src/io.rs b/tvix/eval/src/io.rs
index 7e8b85c87abb..f30ef164c41a 100644
--- a/tvix/eval/src/io.rs
+++ b/tvix/eval/src/io.rs
@@ -48,6 +48,20 @@ impl std::fmt::Display for FileType {
     }
 }
 
+impl From<std::fs::FileType> for FileType {
+    fn from(value: std::fs::FileType) -> Self {
+        if value.is_file() {
+            Self::Regular
+        } else if value.is_dir() {
+            Self::Directory
+        } else if value.is_symlink() {
+            Self::Symlink
+        } else {
+            Self::Unknown
+        }
+    }
+}
+
 /// Represents all possible filesystem interactions that exist in the Nix
 /// language, and that need to be executed somehow.
 ///