pub struct PackRules {
pub custom_secret_count: usize,
pub custom_keep_count: usize,
pub custom_cache_count: usize,
/* private fields */
}Expand description
Compiled classification rules used by the scan.
Fields§
§custom_secret_count: usizeHow many of the compiled patterns came from the operator, for reporting.
custom_keep_count: usizeHow many keep patterns came from the operator, for reporting.
custom_cache_count: usizeHow many cache directory names came from the operator, for reporting.
Implementations§
Source§impl PackRules
impl PackRules
Sourcepub fn new(overrides: &RuleOverrides) -> Result<Self, PackError>
pub fn new(overrides: &RuleOverrides) -> Result<Self, PackError>
Compile the built-in rules plus the operator’s additions.
§Arguments
overrides— Extra globs and directory names from[pack].
§Returns
Rules ready to classify paths.
§Errors
PackError::BadPattern when an operator-supplied glob is malformed,
naming the offending pattern. A typo in config must fail loudly rather
than silently classifying nothing.
Sourcepub fn no_link_report_match(&self, name: &str, rel: &str) -> Option<&str>
pub fn no_link_report_match(&self, name: &str, rel: &str) -> Option<&str>
The no_link_report glob that covers this path, if the operator
declared one.
§Arguments
name— Link name, no separators.rel— Path relative to the project root,/-separated.
§Returns
The glob exactly as configured, so a caller can record which rule suppressed the report rather than only that something did.
Always None when the operator configured nothing, which is the point:
this crate does not decide on its own that some directory’s links are
expected.
Sourcepub fn is_cache_dir(&self, name: &str, rel: &str) -> bool
pub fn is_cache_dir(&self, name: &str, rel: &str) -> bool
Whether a directory is a regenerable cache.
§Arguments
name— Directory name, no separators.rel— Path relative to the project root,/-separated.
Sourcepub fn classify(&self, name: &str, rel: &str) -> FileVerdict
pub fn classify(&self, name: &str, rel: &str) -> FileVerdict
Classify a file against the secret and keep lists.
§Arguments
name— File name, no separators.rel— Path relative to the project root,/-separated.
§Returns
Which of the three outcomes applies, naming every glob involved. A
keep rule outranking a secret rule yields
FileVerdict::KeptOverSecret rather than FileVerdict::Ordinary,
so the caller can record that the file was carried past the secret list
on purpose.
Sourcepub fn secret_pattern_count(&self) -> usize
pub fn secret_pattern_count(&self) -> usize
Total number of secret patterns in force.
Sourcepub fn is_customized(&self) -> bool
pub fn is_customized(&self) -> bool
Whether the operator customized anything.