use std::path::PathBuf;
#[derive(Debug, Clone, PartialEq)]
pub enum ProgressEvent {
FileIndexingStarted { path: PathBuf, digest: String },
FileIndexingCompleted {
path: PathBuf,
symbols: u32,
refs: u32,
},
FileAstIndexed { path: PathBuf },
StandardLibraryStarted {
context_file: PathBuf,
stdlib_version: String,
},
StandardLibraryCompleted { symbols: u32, filtered: u32 },
OverallIndexingStarted,
OverallProgress {
current: u32,
total: u32,
percentage: u8,
message: Option<String>,
},
OverallCompleted,
FileAstFailed { path: PathBuf },
IndexingFailed { error: String },
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_progress_event_creation() {
let event = ProgressEvent::FileIndexingStarted {
path: PathBuf::from("/test/file.cpp"),
digest: "ABC123".to_string(),
};
match event {
ProgressEvent::FileIndexingStarted { path, digest } => {
assert_eq!(path, PathBuf::from("/test/file.cpp"));
assert_eq!(digest, "ABC123");
}
_ => panic!("Wrong event type"),
}
}
#[test]
fn test_file_ast_failed_event_creation() {
let event = ProgressEvent::FileAstFailed {
path: PathBuf::from("/test/failed.cpp"),
};
match event {
ProgressEvent::FileAstFailed { path } => {
assert_eq!(path, PathBuf::from("/test/failed.cpp"));
}
_ => panic!("Wrong event type"),
}
}
}