pub struct RulesConfig(/* private fields */);Expand description
ESLint-style per-rule severity overrides.
Keys are either:
- A rule suffix —
"SegmentDuration"— matched against the part of the issue code after the last/. - A full normalised code —
"ST2067-3:2020:7.2.2/SegmentDuration".
Values are the desired RuleSeverity, or RuleSeverity::Off to
suppress the rule entirely.
An empty map (the default) is a no-op.
Implementations§
Source§impl RulesConfig
impl RulesConfig
Sourcepub fn set(&mut self, code: impl ValidationCode, severity: RuleSeverity)
pub fn set(&mut self, code: impl ValidationCode, severity: RuleSeverity)
Set the severity for a typed validation code.
use imferno_core::diagnostics::rules::{RulesConfig, RuleSeverity};
use imferno_core::assetmap::codes::St2067_2_2020;
let mut rules = RulesConfig::default();
rules.set(St2067_2_2020::FileNotFound, RuleSeverity::Critical);Sourcepub fn set_raw(&mut self, key: String, severity: RuleSeverity)
pub fn set_raw(&mut self, key: String, severity: RuleSeverity)
Set severity by raw string key (rule suffix or full code).
Sourcepub fn validate<I, S>(&self, known_codes: I) -> Vec<RuleValidationWarning>
pub fn validate<I, S>(&self, known_codes: I) -> Vec<RuleValidationWarning>
Check the configured keys against a known-code universe and return a list of warnings for keys that match nothing. Useful at config-load time so operators get fast feedback on typos and unsupported syntax.
The caller supplies the known-code universe (typically obtained from
the listRules enumerator on the NAPI/wasm boundary, or by iterating
every typed code enum’s ALL const).
Warning categories:
UnknownSource—source:FoowhereFooisn’t a known variant.MatchesNothing— the key parsed fine but didn’t match any code inknown_codes(typo, removed rule, or fictional namespace).UnsupportedPattern— syntax we don’t implement (e.g.**).
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &RuleSeverity)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &RuleSeverity)>
Iterate over configured overrides.
Trait Implementations§
Source§impl Clone for RulesConfig
impl Clone for RulesConfig
Source§fn clone(&self) -> RulesConfig
fn clone(&self) -> RulesConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RulesConfig
impl Debug for RulesConfig
Source§impl Default for RulesConfig
impl Default for RulesConfig
Source§fn default() -> RulesConfig
fn default() -> RulesConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for RulesConfig
impl<'de> Deserialize<'de> for RulesConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RulesConfig
impl RefUnwindSafe for RulesConfig
impl Send for RulesConfig
impl Sync for RulesConfig
impl Unpin for RulesConfig
impl UnsafeUnpin for RulesConfig
impl UnwindSafe for RulesConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more