use std::path::{Path, PathBuf};
use async_trait::async_trait;
use super::WatchError;
#[derive(Debug, Clone)]
pub enum WatchAction {
ReindexCode { path: PathBuf },
ReindexDocument { path: PathBuf },
RemoveCode { path: PathBuf },
RemoveDocument { path: PathBuf },
ReloadConfig {
added: Vec<PathBuf>,
removed: Vec<PathBuf>,
},
None,
}
#[async_trait]
pub trait WatchHandler: Send + Sync {
fn name(&self) -> &str;
fn matches(&self, path: &Path) -> bool;
async fn tracked_paths(&self) -> Vec<PathBuf>;
async fn on_modify(&self, path: &Path) -> Result<WatchAction, WatchError>;
async fn on_delete(&self, path: &Path) -> Result<WatchAction, WatchError>;
async fn refresh_paths(&self) -> Result<(), WatchError> {
Ok(())
}
}