use crate::{Dir, File};
use std::path::Path;
#[derive(Debug, Clone, PartialEq)]
pub enum DirEntry<'a> {
Dir(Dir<'a>),
File(File<'a>),
}
impl<'a> DirEntry<'a> {
pub fn path(&self) -> &'a Path {
match self {
DirEntry::Dir(d) => d.path(),
DirEntry::File(f) => f.path(),
}
}
pub fn as_dir(&self) -> Option<&Dir<'a>> {
match self {
DirEntry::Dir(d) => Some(d),
DirEntry::File(_) => None,
}
}
pub fn as_file(&self) -> Option<&File<'a>> {
match self {
DirEntry::File(f) => Some(f),
DirEntry::Dir(_) => None,
}
}
pub fn children(&self) -> &'a [DirEntry<'a>] {
match self {
DirEntry::Dir(d) => d.entries(),
DirEntry::File(_) => &[],
}
}
}