weavatrix_scan/report/
scan.rs1use super::{
2 PathBuf, ScanCacheStats, ScanReport, ScanTermination, ScanWarning, SkipKind, SkippedEntry,
3};
4
5impl ScanReport {
6 #[must_use]
8 pub fn delta_from(&self, previous: &Self) -> crate::ScanDelta {
9 crate::ScanDelta::between(previous, self)
10 }
11
12 pub(crate) fn new(root: PathBuf, record_skipped: bool) -> Self {
13 Self {
14 root,
15 files: Vec::new(),
16 skipped: Vec::new(),
17 warnings: Vec::new(),
18 ignore_sources: Vec::new(),
19 revision: String::new(),
20 complete: true,
21 termination: None,
22 portable: true,
23 cache: ScanCacheStats::default(),
24 record_skipped,
25 }
26 }
27
28 pub(crate) fn skip(&mut self, relative: String, kind: SkipKind, detail: Option<String>) {
29 if self.record_skipped {
30 self.skipped.push(SkippedEntry {
31 relative,
32 kind,
33 detail,
34 });
35 }
36 }
37
38 pub(crate) fn skip_borrowed(&mut self, relative: &str, kind: SkipKind, detail: Option<String>) {
39 if self.record_skipped {
40 self.skipped.push(SkippedEntry {
41 relative: relative.to_owned(),
42 kind,
43 detail,
44 });
45 }
46 }
47
48 pub(crate) fn warn(&mut self, relative: Option<String>, message: impl Into<String>) {
49 self.complete = false;
50 self.warnings.push(ScanWarning {
51 relative,
52 message: message.into(),
53 });
54 }
55
56 pub(crate) fn terminate(&mut self, reason: ScanTermination) {
57 self.complete = false;
58 self.termination.get_or_insert(reason);
59 }
60
61 pub(crate) fn finish_recording(&mut self) {
62 self.record_skipped = true;
63 }
64}