Skip to main content

Rule

Trait Rule 

Source
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§

Source

fn id(&self) -> &'static str

Stable identifier, <category>/<id> (e.g. spacing/hard-coded-gap).

Source

fn default_severity(&self) -> Severity

Default severity if the user’s config doesn’t override it.

Source

fn summary(&self) -> &'static str

One-line human-readable summary. Shown in plumb list-rules.

Source

fn check( &self, ctx: &SnapshotCtx<'_>, config: &Config, sink: &mut ViolationSink<'_>, )

Evaluate the rule against a snapshot.

Provided Methods§

Source

fn doc_url(&self) -> String

Canonical documentation URL for this rule.

Implementors§

Source§

impl Rule for TouchTarget

Source§

impl Rule for Rhythm

Source§

impl Rule for ContrastAa

Source§

impl Rule for PaletteConformance

Source§

impl Rule for NearAlignment

Source§

impl Rule for plumb_core::rules::opacity::scale_conformance::ScaleConformance

Source§

impl Rule for plumb_core::rules::radius::scale_conformance::ScaleConformance

Source§

impl Rule for plumb_core::rules::shadow::scale_conformance::ScaleConformance

Source§

impl Rule for HeightConsistency

Source§

impl Rule for PaddingConsistency

Source§

impl Rule for GridConformance

Source§

impl Rule for plumb_core::rules::spacing::scale_conformance::ScaleConformance

Source§

impl Rule for FamilyConformance

Source§

impl Rule for plumb_core::rules::type_::scale_conformance::ScaleConformance

Source§

impl Rule for WeightConformance

Source§

impl Rule for plumb_core::rules::z::scale_conformance::ScaleConformance