use std::path::{Path, PathBuf};
pub struct WalkerConfig {
pub rules: Vec<WalkerRule>,
pub follow_symlinks: bool,
pub drop_empty_dirs: bool,
}
impl WalkerConfig {
pub fn new(rules: Vec<WalkerRule>) -> Self {
Self {
rules,
follow_symlinks: false,
drop_empty_dirs: false,
}
}
}
pub struct WalkerRule {
pub name: &'static str,
pub description: Option<String>,
pub only_for: Option<WalkerItemType>,
pub matches: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> bool>,
pub action: Box<dyn Fn(&Path, &WalkerConfig, &Path) -> Result<WalkerRuleResult, std::io::Error>>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WalkerItemType {
Directory,
File,
Symlink,
}
#[derive(Debug, Clone)]
pub enum WalkerRuleResult {
StrError(String),
SkipRule,
IncludeItem,
IncludeItemAbsolute,
ExcludeItem,
MapAsList(Vec<PathBuf>, bool),
}