Skip to main content

Crate subx_cli

Crate subx_cli 

Source
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:

  • cli - Command-line interface and argument parsing
  • commands - Implementation of all SubX commands

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::parallel for 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 crates

Modules§

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 the subx-core crate.
create_production_config_service_with_empty_env
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
create_production_config_service_with_env
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
create_test_config_service
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_production_config_with_env
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_production_config_with_openai_env
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_ai_config
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_ai_config_and_key
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_config
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_default_config
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_parallel_config
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.
test_with_sync_config
All twelve #[macro_export] configuration test macros, re-exported from the subx-core crate.

Structs§

App
Main application structure with dependency injection support.
Config
Root configuration types.
ProductionConfigService
Production configuration service implementation.
SystemEnvironmentProvider
System environment variable provider implementation.
TestConfigBuilder
Fluent builder for creating test configurations.
TestConfigService
Test configuration service implementation.
TestEnvironmentProvider
Test environment variable provider implementation.

Constants§

CORE_VERSION
Version of the subx-core library this build is linked against.
VERSION
Library version string.

Traits§

ConfigService
Configuration service trait for dependency injection.
EnvironmentProvider
Environment variable provider trait.

Type Aliases§

Result
Convenient type alias for Result<T, SubXError>.