1use std::sync::Arc;
4
5use crate::diagnostic::Diagnostic;
6use crate::graph::Graph;
7use crate::model::{DocPath, Record};
8
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum Mode {
11 Check,
12 Report,
13 Watch,
14}
15
16#[derive(Clone, Copy, Debug, PartialEq, Eq)]
17pub struct RunId(pub u64);
18
19#[derive(Clone, Debug)]
21pub struct Artifact {
22 pub path: DocPath,
23 pub bytes: Vec<u8>,
24}
25
26#[derive(Clone, Debug, Default)]
27pub struct RunSummary {
28 pub errors: usize,
29 pub warnings: usize,
30}
31
32impl RunSummary {
33 pub fn exit_code(&self) -> i32 {
34 if self.errors > 0 { 1 } else { 0 }
35 }
36}
37
38#[derive(Clone, Debug)]
39pub struct ParseError(pub String);
40
41pub enum Event {
42 RunStarted { run: RunId, mode: Mode },
43 Discovered(DocPath),
44 Changed(DocPath),
45 Removed(DocPath),
46 Settled,
48 Parsed(Arc<Record>),
49 ParseFailed { path: DocPath, error: ParseError },
50 GraphBuilt(Arc<Graph>),
51 Diagnostic(Diagnostic),
52 Report(Artifact),
53 RunFinished(RunSummary),
54}