use std::path::Path;
#[allow(dead_code)]
pub struct WatchConfig {
pub paths: Vec<String>,
pub extensions: Vec<String>,
pub debounce_ms: u64,
pub ignore: Vec<String>,
}
impl Default for WatchConfig {
fn default() -> Self {
Self {
paths: vec!["src".to_string()],
extensions: vec!["rs".to_string()],
debounce_ms: 500,
ignore: vec![
"target".to_string(),
".git".to_string(),
"node_modules".to_string(),
],
}
}
}
#[allow(dead_code)]
pub fn should_ignore(path: &Path, patterns: &[String]) -> bool {
let path_str = path.to_string_lossy();
patterns.iter().any(|p| path_str.contains(p))
}
#[allow(dead_code)]
pub fn has_watched_extension(path: &Path, extensions: &[String]) -> bool {
path.extension()
.and_then(|ext| ext.to_str())
.map(|ext| extensions.iter().any(|e| e == ext))
.unwrap_or(false)
}