use std::sync::Arc;
use crate::diagnostic::Diagnostic;
use crate::graph::Graph;
use crate::model::{DocPath, Record};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Mode {
Check,
Report,
Watch,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct RunId(pub u64);
#[derive(Clone, Debug)]
pub struct Artifact {
pub path: DocPath,
pub bytes: Vec<u8>,
}
#[derive(Clone, Debug, Default)]
pub struct RunSummary {
pub errors: usize,
pub warnings: usize,
}
impl RunSummary {
pub fn exit_code(&self) -> i32 {
if self.errors > 0 { 1 } else { 0 }
}
}
#[derive(Clone, Debug)]
pub struct ParseError(pub String);
pub enum Event {
RunStarted { run: RunId, mode: Mode },
Discovered(DocPath),
Changed(DocPath),
Removed(DocPath),
Settled,
Parsed(Arc<Record>),
ParseFailed { path: DocPath, error: ParseError },
GraphBuilt(Arc<Graph>),
Diagnostic(Diagnostic),
Report(Artifact),
RunFinished(RunSummary),
}