Expand description
SubX: Intelligent Subtitle Processing Library
SubX is a comprehensive Rust library for intelligent subtitle file processing, featuring AI-powered matching, format conversion, audio synchronization, and advanced encoding detection capabilities.
§Key Features
- AI-Powered Matching: Intelligent subtitle file matching and renaming
- Format Conversion: Support for multiple subtitle formats (SRT, ASS, VTT, etc.)
- Audio Synchronization: Advanced audio-subtitle timing adjustment
- Encoding Detection: Automatic character encoding detection and conversion
- Parallel Processing: High-performance batch operations
- Configuration Management: Flexible multi-source configuration system
§Architecture Overview
The library is organized into several key modules:
The config, core, error and services modules are owned by
the subx_core crate — the library half of the SubX two-crate split, a
git submodule mounted at subx-core/ and a member of this Cargo
workspace. They are re-exported below under their pre-split paths so
existing consumers keep compiling; subx_core:: is the canonical path.
§Quick Start
use subx_cli::config::{TestConfigService, ConfigService};
// Create a configuration service
let config_service = TestConfigService::with_defaults();
let config = config_service.config();
// Use the configuration for processing...§Error Handling
All operations return a Result<T> type that wraps error::SubXError:
use subx_cli::{Result, error::SubXError};
fn example_operation() -> Result<String> {
// This could fail with various error types
Err(SubXError::config("Missing configuration"))
}§Configuration
SubX supports dependency injection-based configuration:
use subx_cli::config::{TestConfigService, Config};
// Create configuration service with AI settings
let config_service = TestConfigService::with_ai_settings("openai", "gpt-4.1");
let config = config_service.config();
// Access configuration values
println!("AI Provider: {}", config.ai.provider);
println!("AI Model: {}", config.ai.model);§Performance Considerations
- Use
core::parallelfor batch operations on large file sets - Configure appropriate cache settings for repeated operations
- Consider memory usage when processing large audio files
§Thread Safety
The library is designed to be thread-safe where appropriate:
- Configuration manager uses
Arc<RwLock<T>>for shared state - File operations include rollback capabilities for atomicity
- Parallel processing uses safe concurrency patterns
§Feature Flags
Both optional features of this crate are pass-throughs that enable the
matching gate in the subx-core crate (where the gated sources live) and
nothing else:
- archive-rar - enable RAR archive extraction (optional unrar dependency)
- slow-tests - compile long-running tests in both cratesModules§
- cli
- Command-line interface for the SubX subtitle processing tool.
- commands
- SubX command execution module.
- config
- Configuration management and validation.
- core
- Core processing engines (formats, matching, sync).
- error
- Comprehensive error handling system.
- services
- External service integrations (AI, audio processing).
Macros§
- create_
default_ test_ config_ service - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - create_
production_ config_ service_ with_ empty_ env - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - create_
production_ config_ service_ with_ env - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - create_
test_ config_ service - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
production_ config_ with_ env - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
production_ config_ with_ openai_ env - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ ai_ config - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ ai_ config_ and_ key - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ config - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ default_ config - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ parallel_ config - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate. - test_
with_ sync_ config - All twelve
#[macro_export]configuration test macros, re-exported from thesubx-corecrate.
Structs§
- App
- Main application structure with dependency injection support.
- Config
- Root configuration types.
- Production
Config Service - Production configuration service implementation.
- System
Environment Provider - System environment variable provider implementation.
- Test
Config Builder - Fluent builder for creating test configurations.
- Test
Config Service - Test configuration service implementation.
- Test
Environment Provider - Test environment variable provider implementation.
Constants§
- CORE_
VERSION - Version of the
subx-corelibrary this build is linked against. - VERSION
- Library version string.
Traits§
- Config
Service - Configuration service trait for dependency injection.
- Environment
Provider - Environment variable provider trait.
Type Aliases§
- Result
- Convenient type alias for
Result<T, SubXError>.