diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-15T23·04+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-16T00·16+0000 |
commit | da9a6e5b782b9864b625135ebaaf4a12b9d0018e (patch) | |
tree | 51b8738cb008dcf0746c57e86deef75ae8edb3cf | |
parent | a833703dab8c4ef271cb8ae11df2ca5fa46c7343 (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>
-rw-r--r-- | tvix/eval/src/io.rs | 14 |
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. /// |