Skip to main content

RulesConfig

Struct RulesConfig 

Source
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

Source

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);
Source

pub fn set_raw(&mut self, key: String, severity: RuleSeverity)

Set severity by raw string key (rule suffix or full code).

Source

pub fn is_empty(&self) -> bool

Returns true if no overrides are configured.

Source

pub fn len(&self) -> usize

Number of configured overrides.

Source

pub fn validate<I, S>(&self, known_codes: I) -> Vec<RuleValidationWarning>
where I: IntoIterator<Item = S>, S: AsRef<str>,

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:

  • UnknownSourcesource:Foo where Foo isn’t a known variant.
  • MatchesNothing — the key parsed fine but didn’t match any code in known_codes (typo, removed rule, or fictional namespace).
  • UnsupportedPattern — syntax we don’t implement (e.g. **).
Source

pub fn iter(&self) -> impl Iterator<Item = (&String, &RuleSeverity)>

Iterate over configured overrides.

Trait Implementations§

Source§

impl Clone for RulesConfig

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for RulesConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RulesConfig

Source§

fn default() -> RulesConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RulesConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for RulesConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.