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 config;
47pub mod error;
48pub mod cli;
49pub mod api;
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 config::{Config, OcrConfig, ModelConfig, PreprocessConfig, OutputConfig, PerformanceConfig, CacheConfig};
76pub use error::{ScipixError, Result};
77pub use cli::{Cli, Commands};
78pub use api::{ApiServer, state::AppState};
79
80#[cfg(feature = "cache")]
81pub use cache::CacheManager;
82
83/// Library version
84pub const VERSION: &str = env!("CARGO_PKG_VERSION");
85
86/// Default configuration preset
87pub fn default_config() -> Config {
88    Config::default()
89}
90
91/// High-accuracy configuration preset
92pub fn high_accuracy_config() -> Config {
93    Config::high_accuracy()
94}
95
96/// High-speed configuration preset
97pub fn high_speed_config() -> Config {
98    Config::high_speed()
99}
100
101#[cfg(test)]
102mod tests {
103    use super::*;
104
105    #[test]
106    fn test_version() {
107        assert!(!VERSION.is_empty());
108    }
109
110    #[test]
111    fn test_default_config() {
112        let config = default_config();
113        assert!(config.validate().is_ok());
114    }
115
116    #[test]
117    fn test_high_accuracy_config() {
118        let config = high_accuracy_config();
119        assert!(config.validate().is_ok());
120    }
121
122    #[test]
123    fn test_high_speed_config() {
124        let config = high_speed_config();
125        assert!(config.validate().is_ok());
126    }
127}