BuiltinRules

Struct BuiltinRules 

Source
pub struct BuiltinRules;
Available on crate feature analysis only.
Expand description

Built-in lint rules registry

Provides access to all built-in rules that check for common issues in ASS subtitle scripts. Rules are organized by category and can be used individually or as a complete set.

§Performance

All rules are designed for efficient execution with minimal memory overhead. Most rules have O(n) or O(n log n) time complexity.

§Rule List

  • TimingOverlapRule: Detects overlapping dialogue events
  • NegativeDurationRule: Finds events with invalid durations
  • InvalidColorRule: Validates color formats in styles and tags
  • MissingStyleRule: Checks for undefined style references
  • InvalidTagRule: Detects malformed override tags
  • PerformanceRule: Identifies performance-impacting patterns
  • EncodingRule: Validates text encoding and character usage
  • AccessibilityRule: Ensures readability and compatibility

Implementations§

Source§

impl BuiltinRules

Source

pub fn all_rules() -> Vec<Box<dyn LintRule>>

Get all built-in linting rules

Returns a vector of all available built-in rules ready for use. Rules are returned in their default configuration with standard severity levels and categories.

§Example
use ass_core::analysis::linting::rules::BuiltinRules;

let rules = BuiltinRules::all_rules();
assert_eq!(rules.len(), 8); // All built-in rules
Source

pub fn rules_for_category(category: IssueCategory) -> Vec<Box<dyn LintRule>>

Get rules by category

Returns only rules that check issues in the specified category. Useful for focused linting or when only certain types of issues need to be checked.

§Arguments
  • category - The issue category to filter by
§Example
use ass_core::analysis::linting::{IssueCategory, rules::BuiltinRules};

let timing_rules = BuiltinRules::rules_for_category(IssueCategory::Timing);
// Returns timing-related rules only
Source

pub fn rule_by_id(id: &str) -> Option<Box<dyn LintRule>>

Get rule by ID

Returns the rule with the specified ID, or None if no such rule exists. Rule IDs are unique identifiers used for configuration and reporting.

§Arguments
  • id - The rule ID to search for
§Example
use ass_core::analysis::linting::rules::BuiltinRules;

let rule = BuiltinRules::rule_by_id("timing-overlap");
assert!(rule.is_some());
assert_eq!(rule.unwrap().id(), "timing-overlap");
Source

pub fn all_rule_ids() -> Vec<&'static str>

Get all rule IDs

Returns a vector of all available rule IDs for configuration and reporting purposes.

§Example
use ass_core::analysis::linting::rules::BuiltinRules;

let ids = BuiltinRules::all_rule_ids();
assert!(ids.contains(&"timing-overlap"));
assert!(ids.contains(&"negative-duration"));

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> 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, 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.