ruvector_scipix/cli/commands/
mod.rs

1pub mod ocr;
2pub mod batch;
3pub mod serve;
4pub mod config;
5pub mod mcp;
6pub mod doctor;
7
8use serde::{Deserialize, Serialize};
9use std::path::PathBuf;
10
11/// Common result structure for OCR operations
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct OcrResult {
14    /// Source file path
15    pub file: PathBuf,
16
17    /// Extracted text content
18    pub text: String,
19
20    /// LaTeX representation (if available)
21    pub latex: Option<String>,
22
23    /// Confidence score (0.0 to 1.0)
24    pub confidence: f64,
25
26    /// Processing time in milliseconds
27    pub processing_time_ms: u64,
28
29    /// Any errors or warnings
30    pub errors: Vec<String>,
31}
32
33impl OcrResult {
34    /// Create a new OCR result
35    pub fn new(file: PathBuf, text: String, confidence: f64) -> Self {
36        Self {
37            file,
38            text,
39            latex: None,
40            confidence,
41            processing_time_ms: 0,
42            errors: Vec::new(),
43        }
44    }
45
46    /// Set LaTeX content
47    pub fn with_latex(mut self, latex: String) -> Self {
48        self.latex = Some(latex);
49        self
50    }
51
52    /// Set processing time
53    pub fn with_processing_time(mut self, time_ms: u64) -> Self {
54        self.processing_time_ms = time_ms;
55        self
56    }
57
58    /// Add an error message
59    pub fn add_error(&mut self, error: String) {
60        self.errors.push(error);
61    }
62}
63
64/// Configuration for OCR processing
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct OcrConfig {
67    /// Minimum confidence threshold
68    pub min_confidence: f64,
69
70    /// Maximum image size in bytes
71    pub max_image_size: usize,
72
73    /// Supported file extensions
74    pub supported_extensions: Vec<String>,
75
76    /// API endpoint (if using remote service)
77    pub api_endpoint: Option<String>,
78
79    /// API key (if using remote service)
80    pub api_key: Option<String>,
81}
82
83impl Default for OcrConfig {
84    fn default() -> Self {
85        Self {
86            min_confidence: 0.7,
87            max_image_size: 10 * 1024 * 1024, // 10MB
88            supported_extensions: vec![
89                "png".to_string(),
90                "jpg".to_string(),
91                "jpeg".to_string(),
92                "pdf".to_string(),
93                "gif".to_string(),
94            ],
95            api_endpoint: None,
96            api_key: None,
97        }
98    }
99}