pub trait Rule: Send + Sync {
// Required methods
fn id(&self) -> &'static str;
fn default_severity(&self) -> Severity;
fn summary(&self) -> &'static str;
fn check(
&self,
ctx: &SnapshotCtx<'_>,
config: &Config,
sink: &mut ViolationSink<'_>,
);
// Provided method
fn doc_url(&self) -> String { ... }
}Expand description
A rule — the fundamental unit of work in the engine.
Rules are Send + Sync so the engine can evaluate built-in rules in
parallel against one shared snapshot context. Implementations must be
pure: given the same ctx and config, they must push the same
sequence of violations into their local sink every time. Do not rely on
shared mutable state, I/O, clocks, environment variables, randomness, or
cross-rule ordering; each rule must be safe to run concurrently with any
other rule.
Required Methods§
Sourcefn default_severity(&self) -> Severity
fn default_severity(&self) -> Severity
Default severity if the user’s config doesn’t override it.
Sourcefn check(
&self,
ctx: &SnapshotCtx<'_>,
config: &Config,
sink: &mut ViolationSink<'_>,
)
fn check( &self, ctx: &SnapshotCtx<'_>, config: &Config, sink: &mut ViolationSink<'_>, )
Evaluate the rule against a snapshot.