v0.2 to v0.3
RustO! v0.3.0 is a major architectural release that transitions the entire core engine to pure Rust, eliminates C++/CMake toolchain dependencies, and streamlines the configuration API across all supported languages.
⚡ Quick Upgrade Summary
| Aspect | v0.2.x | v0.3.0 (Current) |
|---|---|---|
| Core Inference Engine | Alibaba MNN (requires C++ / CMake) | Pure Rust RTen (zero C++ toolchain) |
| Model Formats | Proprietary .mnn | FlatBuffers .rten or standard .onnx |
| Inference Session API | MnnSession | EngineSession (implements InferenceSession) |
| Configuration Model | Nested preprocessing block in static config | Decoupled InitializeConfig & OcrRunOptions |
| NPM Package Names | Standalone (react-rusto, rusto-web) | Scoped @rustors/* (@rustors/react, @rustors/web) |
1. Engine Architecture & Model Formats
Zero C++ / CMake Toolchain
In v0.2, RustO relied on Alibaba MNN via C FFI bindings. This required CMake, platform-specific C++ compilers, and complex NDK/Xcode toolchain integration.
In v0.3, the default inference engine is 100% pure Rust powered by RTen. Compiling RustO only requires standard Cargo (cargo build), with zero native shared libraries or build-time dependencies.
Transitioning Model Formats
Proprietary .mnn models are deprecated. Update your model references to .rten (FlatBuffers) or .onnx:
- det_model: "models/det.mnn"
- rec_model: "models/rec.mnn"
+ det_model: "models/det.rten"
+ rec_model: "models/rec.rten"
Pre-converted .rten and .onnx models are available on GitHub Releases, npm, and NuGet.
2. Session API: EngineSession
The concrete MnnSession struct has been removed in favor of EngineSession, which implements the generic InferenceSession trait.
Before (v0.2)
use rusto::session::MnnSession;
let det_session = MnnSession::from_file("models/det.mnn")?;
After (v0.3)
use rusto::session::EngineSession;
// Using built-in RTen backend:
let det_session = EngineSession::from_det_config(&config.det)?;
let rec_session = EngineSession::from_rec_config(&config.rec)?;
// Or wrap custom third-party engines (e.g. ONNX Runtime ort, Tract):
let custom_session = EngineSession::from_custom(my_session_box);
let ocr = RustO::with_custom_engines(config, det_session, rec_session)?;
3. Configuration & Runtime Options Refactoring
In v0.2, image preprocessing thresholds and post-processing flags were coupled inside static configuration structures. In v0.3, options are decoupled into two distinct categories:
InitializeConfig: One-time static setup for model paths, vocabulary dictionary, and thread allocation.OcrRunOptions: Per-request options passed intodetect_text(...)orrun_ocr(...).
Flattened Options Structure
The legacy nested preprocessing block has been removed. Detection thresholds and post-processing limits are now direct sibling fields on OcrRunOptions:
Before (v0.2)
// v0.2: Runtime thresholds mutated static engine configuration
let mut config = Config::from_files("det.mnn", "rec.mnn", "dict.txt")?;
config.preprocessing.det_db_thresh = 0.3;
config.preprocessing.det_db_box_thresh = 0.6;
config.preprocessing.det_db_unclip_ratio = 1.6;
let mut ocr = RustO::new(config)?;
let result = ocr.run(&image)?;
After (v0.3)
use rusto::{InitializeConfig, OcrRunOptions, OutputGranularity, RustO};
// 1. Static initialization (thread-safe, load once)
let mut ocr = RustO::initialize(InitializeConfig::ppv6(
"models/det.rten",
"models/rec.rten",
"models/dict.txt",
))?;
// 2. Per-request options (stateless, concurrent)
let mut options = OcrRunOptions::default();
options.detection.box_threshold = 0.6;
options.postprocess.unclip_ratio = 1.6;
options.output_granularity = OutputGranularity::Lines;
// Optional: Document calibration & resolution scaling
options.calibration.descreen = true;
options.optimization.max_side_len = 960;
let result = ocr.detect_text(&image, &options)?;
4. Package Namespaces Migration (@rustors/*)
All npm packages have migrated to the official @rustors organization scope:
| Legacy Package (v0.2) | Official Package (v0.3) | Notes |
|---|---|---|
react-native-rusto | @rustors/react-native | Native JNI/TurboModule bridge |
rusto-web | @rustors/web | Browser WASM RTen engine |
react-rusto | @rustors/react | React hooks & context provider |
rusto-models-ppocrv6-* | @rustors/model-ppocrv6-* | Prepackaged .rten model bundles |
Updating package.json
"dependencies": {
- "react-native-rusto": "^0.2.4",
- "rusto-models-ppocrv6-tiny": "^0.2.4"
+ "@rustors/react-native": "^0.3.0",
+ "@rustors/model-ppocrv6-tiny": "^0.3.0"
}
5. Mobile & Native Packages
- Android (JitPack / Gradle):
// app/build.gradle implementation 'com.github.byrizki.rusto-rs:rusto-android:0.3.0' implementation 'com.github.byrizki.rusto-rs:rusto-models-ppocrv6-tiny:0.3.0' - iOS (CocoaPods):
# Podfile pod 'RustO', '~> 0.3.0' pod 'RustO-Models-PPOCRv6-Tiny', '~> 0.3.0' - .NET (NuGet):
dotnet add package RustODotnet --version 0.3.0 dotnet add package RustODotnet.Models.PPOCRv6.Tiny --version 0.3.0
6. Migration Checklist
- Step 1: Replace model files (
.mnn) with.rtenor.onnxmodels. - Step 2: Update dependencies to
0.3.0(using@rustors/*for npm). - Step 3: Replace
MnnSessionreferences withEngineSession. - Step 4: Separate static
InitializeConfigfrom per-imageOcrRunOptions. - Step 5: Flatten configuration fields (replace nested
preprocessing.*withoptions.detection.*andoptions.postprocess.*). - Step 6: Validate OCR output and bounding boxes on test images.