Struct EncodingRule

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

Rule for detecting encoding and character issues in subtitle scripts

Analyzes scripts for problematic characters that may cause encoding issues, display problems, or compatibility issues across different subtitle renderers and media players.

§Encoding Checks

  • Non-printable characters: Detects control characters that shouldn’t appear in text
  • Invalid UTF-8 sequences: Identifies corrupted character data
  • Suspicious character patterns: Warns about potentially problematic sequences

§Performance

  • Time complexity: O(n * m) for n events and m characters per event
  • Memory: O(1) additional space
  • Target: <2ms for typical scripts with 1000 events

§Example

use ass_core::analysis::linting::rules::encoding::EncodingRule;
use ass_core::analysis::linting::LintRule;
use ass_core::{Script, ScriptAnalysis};

let script_text = format!("[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\nDialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,Text with{}invalid character", '\x00');
let script = Script::parse(&script_text)?;

let rule = EncodingRule;
let analysis = ScriptAnalysis::analyze(&script).unwrap();
let issues = rule.check_script(&analysis);
assert!(!issues.is_empty()); // Should detect the control character

Trait Implementations§

Source§

impl LintRule for EncodingRule

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.