infrastructure capa

infrastructure-ocr-provider

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).

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).

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/ocr-provider
Edition2021
Targetsinfrastructure_ocr_provider
Public items5 across 0 modules
Tests3

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`

ItemWhat it is
pub enum OcrProviderTypeWhich OCR provider to use
OcrProviderType :: fn is_local(& self) -> boolWhether this provider keeps the image on-host (no egress).
pub struct OcrSettingsPersisted OCR configuration (preferences system)
pub enum SelectErrorFailure 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)
Locationcrates/infrastructure/ocr-provider
Vocabulary in force (lexicon)current

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`infrastructure-ai`infrastructurenoalways
`infrastructure-ocr-ai`infrastructurenoalways
`infrastructure-ocr-engine`infrastructurenoalways
`infrastructure-ocr-tesseract`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde^1derive, derivenoalways
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde_json^1noalways
tokio^1full, macros, rt-multi-threadnoalways

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

KindNameSource
libinfrastructure_ocr_provider`src/lib.rs`

Error model

Error typeNamed by
SelectErrorbuild_ocr_engine

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone 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.

No workspace crate depends on this one.

Verification

KindCount
Unit tests3
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root400

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc55
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 5
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files1
Source lines142
Code lines92
Public API items5
Public modules0
Tests3
Examples0
Cargo features0
Direct runtime dependencies6
Workspace reverse dependencies0
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.

Todas las infrastructure · Manual