Struct MissingStyleRule

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

Rule for detecting events that reference undefined styles

Events must reference valid style names defined in the [V4+ Styles] section. Missing style references cause renderers to fall back to default styling, which may not match the intended visual appearance.

§Performance

  • Time complexity: O(n + m) for n styles and m events
  • Memory: O(n) for style name collection
  • Target: <1ms for typical scripts with 100 styles and 1000 events

§Example

use ass_core::analysis::linting::rules::missing_style::MissingStyleRule;
use ass_core::analysis::linting::LintRule;
use ass_core::{Script, ScriptAnalysis};

let script = Script::parse(r#"
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20,&H00FFFFFF&,&H000000FF&,&H00000000&,&H00000000&,0,0,0,0,100,100,0,0,1,2,0,2,10,10,10,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Undefined,,0,0,0,,Text with undefined style
"#)?;

let analysis = ScriptAnalysis::analyze(&script)?;
let rule = MissingStyleRule;
let issues = rule.check_script(&analysis);
assert!(!issues.is_empty()); // Should detect the missing style reference

Trait Implementations§

Source§

impl LintRule for MissingStyleRule

Source§

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

Unique identifier for this rule.
Source§

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

Human-readable name.
Source§

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

Rule description.
Source§

fn default_severity(&self) -> IssueSeverity

Default severity level.
Source§

fn category(&self) -> IssueCategory

Issue category this rule checks for.
Source§

fn check_script(&self, analysis: &ScriptAnalysis<'_>) -> Vec<LintIssue>

Check script and return issues.

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.