layer_conform_core/
rule.rs1use std::path::Path;
7
8use globset::GlobSet;
9
10#[derive(Clone, Debug)]
11pub struct Rule {
12 pub id: String,
13 pub goldens: Vec<GoldenSelector>,
14 pub apply_to: GlobSet,
15 pub ignore: GlobSet,
16 pub threshold: Option<f64>,
17 pub disabled: bool,
18}
19
20#[derive(Clone, Debug, PartialEq, Eq, Hash)]
21pub struct GoldenSelector {
22 pub file: String,
23 pub symbol: String,
24}
25
26impl Rule {
27 pub fn matches(&self, path: &Path) -> bool {
30 if self.disabled {
31 return false;
32 }
33 if !self.apply_to.is_match(path) {
34 return false;
35 }
36 if self.ignore.is_match(path) {
37 return false;
38 }
39 true
40 }
41}