Module utils

Source
Expand description

Utility functions and shared types for ASS-RS core

Contains common functionality used across parser, tokenizer, and analysis modules. Focuses on zero-allocation helpers, color processing, and UTF-8 handling.

§Performance

  • Zero-copy span utilities for AST references
  • SIMD-optimized color conversions when available
  • Minimal allocation math helpers (bezier evaluation)

§Example

use ass_core::utils::{Spans, parse_bgr_color};

let color_str = "&H00FF00FF&";
let rgba = parse_bgr_color(color_str)?;
assert_eq!(rgba, [255, 0, 255, 0]); // BGR -> RGBA

Re-exports§

pub use benchmark_generators::create_test_event;
pub use benchmark_generators::generate_overlapping_script;
pub use benchmark_generators::generate_script_with_issues;
pub use benchmark_generators::ComplexityLevel;
pub use benchmark_generators::ScriptGenerator;
pub use errors::CoreError;
pub use hashers::create_hash_map;
pub use hashers::create_hash_map_with_capacity;
pub use hashers::create_hasher;
pub use hashers::hash_value;
pub use utf8::detect_encoding;
pub use utf8::normalize_line_endings;
pub use utf8::recover_utf8;
pub use utf8::strip_bom;
pub use utf8::validate_utf8;

Modules§

benchmark_generators
Benchmark utilities for generating synthetic ASS scripts
errors
Core error types for ASS-RS utilities and cross-module error handling
hashers
Hash function utilities for consistent performance across platforms
utf8
UTF-8 and text encoding utilities for ASS script processing

Structs§

Spans
Zero-copy span utilities for AST node validation and manipulation

Functions§

decode_uu_data
Decode UU-encoded data commonly found in ASS [Fonts] and [Graphics] sections
eval_cubic_bezier
Evaluate cubic bezier curve at parameter t
format_ass_time
Format centiseconds back to ASS time format
normalize_field_value
Trim and normalize whitespace in ASS field values
parse_ass_time
Parse ASS time format (H:MM:SS.CC) to centiseconds
parse_bgr_color
Parse ASS BGR color format to RGBA bytes
parse_numeric
Parse numeric value from ASS field with validation
validate_ass_name
Check if string contains only valid ASS characters