Settings-driven OCR provider selection: OcrProviderType (local/subscription/api) + OcrSettings + build_ocr_engine(). Composes the ocr-engine trait with the tesseract + ai adapters. For GENERAL consumers — returns a dyn OcrEngine; the DLP path never uses this (it takes E: LocalOcrEngine directly).
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/ocr-provider |
| Edition | 2021 |
| Targets | infrastructure_ocr_provider |
| Public items | 5 across 0 modules |
| Tests | 3 |
What it is for
infrastructure-ocr-provider — settings-driven OCR provider selection.
Maps an OcrSettings (persisted in the preferences system) to a concrete OcrEngine, composing the three recognition crates: local Tesseract, or an AI-vision adapter over any infrastructure-ai provider (subscription Claude CLI / metered API).
Scope: GENERAL consumers only
build_ocr_engine returns Arc<dyn OcrEngine> — provider chosen by settings, for CMS/catalog/document OCR. The DLP screen sensor never uses this: it takes a concrete E: LocalOcrEngine so a remote engine can't compile in. Erasing to dyn OcrEngine here would drop that guarantee, which is exactly why the DLP path stays off this selector.
Key/credential plumbing for remote providers is NOT duplicated here — the caller builds the AiProvider via infrastructure_ai::AiProviderFactory (system/tenant keys) and passes it in; this crate only maps provider -> engine.
Capabilities
crate root
infrastructure-ocr-provider — settings-driven OCR provider selection.
| Item |
|---|
fn build_ocr_engine(settings : & OcrSettings, ai_provider : Option <Arc <dyn AiProvider>>,) -> Result <Arc <dyn OcrEngine>, SelectError> |
OcrProviderType
infrastructure-ocr-provider — settings-driven OCR provider selection.
| Item |
|---|
pub enum OcrProviderType |
OcrProviderType :: fn is_local(& self) -> bool |
OcrSettings
infrastructure-ocr-provider — settings-driven OCR provider selection.
| Item |
|---|
pub struct OcrSettings |
SelectError
infrastructure-ocr-provider — settings-driven OCR provider selection.
| Item |
|---|
pub enum SelectError |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum OcrProviderType | Which OCR provider to use |
OcrProviderType :: fn is_local(& self) -> bool | Whether this provider keeps the image on-host (no egress). |
pub struct OcrSettings | Persisted OCR configuration (preferences system) |
pub enum SelectError | Failure building an engine from settings. |
fn build_ocr_engine(settings : & OcrSettings, ai_provider : Option <Arc <dyn AiProvider>>,) -> Result <Arc <dyn OcrEngine>, SelectError> | Build an OcrEngine from settings |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/ocr-provider |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `infrastructure-ai` | infrastructure | no | always |
| `infrastructure-ocr-ai` | infrastructure | no | always |
| `infrastructure-ocr-engine` | infrastructure | no | always |
| `infrastructure-ocr-tesseract` | infrastructure | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
serde | ^1 | derive, derive | no | always |
thiserror | ^2 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
serde_json | ^1 | — | no | always |
tokio | ^1 | full, macros, rt-multi-thread | no | always |
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["infrastructure-ocr-provider"] SELF -->|runtime| n_infrastructure_ai["infrastructure-ai"] SELF -->|runtime| n_infrastructure_ocr_ai["infrastructure-ocr-ai"] SELF -->|runtime| n_infrastructure_ocr_engine["infrastructure-ocr-engine"] SELF -->|runtime| n_infrastructure_ocr_tesseract["infrastructure-ocr-tesseract"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_ocr_provider | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
SelectError | build_ocr_engine |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 3 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 4 | 0 | 0 |
What the tests establish, by name:
defaults_to_local_and_serdes—src/lib.rslocal_builds_tesseract_without_a_provider—src/lib.rsremote_requires_a_provider—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 5 | 5 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 5
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 142 |
| Code lines | 92 |
| Public API items | 5 |
| Public modules | 0 |
| Tests | 3 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"enum" : 2
"function" : 1
"method" : 1
"struct" : 1
pie showData
title Rust source composition
"Code" : 92
"Blank or comment" : 50
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.