1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
pub mod check;

use parking_lot::Mutex;
use std::{collections::BTreeMap, sync::Arc};

#[derive(Clone, Debug)]
pub struct ReportResult<'d> {
    pub errors: &'d BTreeMap<String, Vec<String>>,
    pub total: usize,
}

pub trait ReportSink {
    fn error(&self, msg: String);
}

/// A no-op report sink
impl ReportSink for () {
    fn error(&self, _msg: String) {}
}

impl ReportSink for (String, Arc<Mutex<BTreeMap<String, Vec<String>>>>) {
    fn error(&self, msg: String) {
        self.1.lock().entry(self.0.clone()).or_default().push(msg);
    }
}