Skip to main content

ass_core/utils/
mod.rs

1//! Utility functions and shared types for ASS-RS core
2//!
3//! Contains common functionality used across parser, tokenizer, and analysis modules.
4//! Focuses on zero-allocation helpers, color processing, and UTF-8 handling.
5//!
6//! # Performance
7//!
8//! - Zero-copy span utilities for AST references
9//! - SIMD-optimized color conversions when available
10//! - Minimal allocation math helpers (bezier evaluation)
11//!
12//! # Example
13//!
14//! ```rust
15//! use ass_core::utils::{Spans, parse_bgr_color};
16//!
17//! let color_str = "&H00FF00FF&";
18//! let rgba = parse_bgr_color(color_str)?;
19//! assert_eq!(rgba, [255, 0, 255, 0]); // BGR -> RGBA
20//! # Ok::<(), Box<dyn std::error::Error>>(())
21//! ```
22
23pub mod benchmark_generators;
24pub mod errors;
25pub mod hashers;
26pub mod utf8;
27
28mod color;
29mod fields;
30mod math;
31mod spans;
32mod time;
33mod uu;
34
35#[cfg(test)]
36mod color_tests;
37#[cfg(test)]
38mod fields_tests;
39#[cfg(test)]
40mod math_tests;
41#[cfg(test)]
42mod spans_tests;
43#[cfg(test)]
44mod time_tests;
45#[cfg(test)]
46mod uu_tests;
47
48pub use benchmark_generators::{
49    create_test_event, generate_overlapping_script, generate_script_with_issues, ComplexityLevel,
50    ScriptGenerator,
51};
52pub use errors::CoreError;
53pub use hashers::{create_hash_map, create_hash_map_with_capacity, create_hasher, hash_value};
54pub use utf8::{detect_encoding, normalize_line_endings, recover_utf8, strip_bom, validate_utf8};
55
56pub use color::parse_bgr_color;
57pub use fields::{normalize_field_value, parse_numeric, validate_ass_name};
58pub use math::eval_cubic_bezier;
59pub use spans::Spans;
60pub use time::{format_ass_time, parse_ass_time};
61pub use uu::decode_uu_data;