feat(tvix/eval/io): impl From<std::fs::FileType> for FileType

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>
This commit is contained in:
Florian Klink 2024-10-16 02:04:17 +03:00 committed by clbot
parent a833703dab
commit da9a6e5b78

View file

@ -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 /// Represents all possible filesystem interactions that exist in the Nix
/// language, and that need to be executed somehow. /// language, and that need to be executed somehow.
/// ///