Skip to main content

ruvector_scipix/
lib.rs

1//! # Ruvector-Scipix
2//!
3//! A high-performance Rust implementation of Scipix OCR for mathematical expressions and equations.
4//! Built on top of ruvector-core for efficient vector-based caching and similarity search.
5//!
6//! ## Features
7//!
8//! - **Mathematical OCR**: Extract LaTeX from images of equations
9//! - **Vector Caching**: Intelligent caching using image embeddings
10//! - **Multiple Formats**: Support for LaTeX, MathML, AsciiMath
11//! - **High Performance**: Parallel processing and efficient caching
12//! - **Configurable**: Extensive configuration options via TOML or API
13//!
14//! ## Quick Start
15//!
16//! ```rust,no_run
17//! use ruvector_scipix::{Config, OcrEngine, Result};
18//!
19//! #[tokio::main]
20//! async fn main() -> Result<()> {
21//!     // Load configuration
22//!     let config = Config::from_file("scipix.toml")?;
23//!
24//!     // Create OCR engine
25//!     let engine = OcrEngine::new(config).await?;
26//!
27//!     // Process image
28//!     let result = engine.process_image("equation.png").await?;
29//!     println!("LaTeX: {}", result.latex);
30//!
31//!     Ok(())
32//! }
33//! ```
34//!
35//! ## Architecture
36//!
37//! - **config**: Configuration management with TOML support
38//! - **error**: Comprehensive error types with context
39//! - **math**: LaTeX and mathematical format handling
40//! - **ocr**: Core OCR processing engine
41//! - **output**: Output formatting and serialization
42//! - **preprocess**: Image preprocessing pipeline
43//! - **cache**: Vector-based intelligent caching
44
45// Module declarations
46pub mod api;
47pub mod cli;
48pub mod config;
49pub mod error;
50
51#[cfg(feature = "cache")]
52pub mod cache;
53
54#[cfg(feature = "ocr")]
55pub mod ocr;
56
57#[cfg(feature = "math")]
58pub mod math;
59
60#[cfg(feature = "preprocess")]
61pub mod preprocess;
62
63// Output module is always available
64pub mod output;
65
66// Performance optimizations
67#[cfg(feature = "optimize")]
68pub mod optimize;
69
70// WebAssembly bindings
71#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
72pub mod wasm;
73
74// Public re-exports
75pub use api::{state::AppState, ApiServer};
76pub use cli::{Cli, Commands};
77pub use config::{
78    CacheConfig, Config, ModelConfig, OcrConfig, OutputConfig, PerformanceConfig, PreprocessConfig,
79};
80pub use error::{Result, ScipixError};
81
82#[cfg(feature = "cache")]
83pub use cache::CacheManager;
84
85/// Library version
86pub const VERSION: &str = env!("CARGO_PKG_VERSION");
87
88/// Default configuration preset
89pub fn default_config() -> Config {
90    Config::default()
91}
92
93/// High-accuracy configuration preset
94pub fn high_accuracy_config() -> Config {
95    Config::high_accuracy()
96}
97
98/// High-speed configuration preset
99pub fn high_speed_config() -> Config {
100    Config::high_speed()
101}
102
103#[cfg(test)]
104mod tests {
105    use super::*;
106
107    #[test]
108    fn test_version() {
109        assert!(!VERSION.is_empty());
110    }
111
112    #[test]
113    fn test_default_config() {
114        let config = default_config();
115        assert!(config.validate().is_ok());
116    }
117
118    #[test]
119    fn test_high_accuracy_config() {
120        let config = high_accuracy_config();
121        assert!(config.validate().is_ok());
122    }
123
124    #[test]
125    fn test_high_speed_config() {
126        let config = high_speed_config();
127        assert!(config.validate().is_ok());
128    }
129}