dd_sds/scanner/
scope.rs

1use crate::Path;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
5#[serde(tag = "type", content = "paths")]
6pub enum Scope {
7    // Only `include` fields are scanned,
8    Include {
9        include: Vec<Path<'static>>,
10        exclude: Vec<Path<'static>>,
11    },
12    // Everything is scanned except the list of fields (children are also excluded)
13    Exclude(Vec<Path<'static>>),
14}
15
16impl Scope {
17    /// All fields of the event are scanned
18    pub fn all() -> Self {
19        Self::Exclude(vec![])
20    }
21
22    /// Paths will be scanned if they are children of any `include` path and NOT children of any `exclude` path
23    pub fn include_and_exclude(include: Vec<Path<'static>>, exclude: Vec<Path<'static>>) -> Self {
24        Self::Include { include, exclude }
25    }
26
27    /// Paths will be scanned if they are children of any `include` path
28    pub fn include(include: Vec<Path<'static>>) -> Self {
29        Self::Include {
30            include,
31            exclude: vec![],
32        }
33    }
34
35    /// Paths will be scanned if they are NOT children of any `exclude` path
36    pub fn exclude(exclude: Vec<Path<'static>>) -> Self {
37        Self::Exclude(exclude)
38    }
39}
40
41impl Default for Scope {
42    fn default() -> Self {
43        Self::all()
44    }
45}