pub struct RuleCoverage {
pub by_rule: BTreeMap<RuleId, BTreeSet<String>>,
pub by_class: BTreeMap<PayloadClass, BTreeSet<RuleId>>,
}Expand description
Accumulates (payload, rule_id) observations from live bench runs and
exposes coverage analytics used by the --coverage-report flag.
Two complementary indices are maintained:
by_rule—rule_id → set of distinct payloads that triggered itby_class—payload_class → set of rule_ids it has reached
Both are updated atomically on every record
call so the coverage report is always consistent.
Fields§
§by_rule: BTreeMap<RuleId, BTreeSet<String>>rule_id → set of payload fingerprints (first 64 chars) observed.
by_class: BTreeMap<PayloadClass, BTreeSet<RuleId>>payload_class → set of rule_ids reached from that class.
Implementations§
Source§impl RuleCoverage
impl RuleCoverage
Sourcepub fn record(&mut self, payload: &str, rule_id: Option<&str>)
pub fn record(&mut self, payload: &str, rule_id: Option<&str>)
Record one (payload, rule_id) observation.
rule_id = None means the request was not blocked (or the block
reason couldn’t be extracted) — the payload class is still indexed
in by_class under a synthetic sentinel so “no rule triggered”
coverage is visible in the report.
Sourcepub fn coverage_report(&self) -> String
pub fn coverage_report(&self) -> String
Produce a human-readable coverage summary.
Each line is rule_id payload_count separated by a tab, sorted
by rule id. Suitable for --coverage-report output.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Number of distinct rule IDs observed so far.
Sourcepub fn triggered_rules(&self) -> Vec<&RuleId>
pub fn triggered_rules(&self) -> Vec<&RuleId>
Rules that have been triggered at least once in this run.
Trait Implementations§
Source§impl Clone for RuleCoverage
impl Clone for RuleCoverage
Source§fn clone(&self) -> RuleCoverage
fn clone(&self) -> RuleCoverage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more