infrastructure tier

infrastructure-ocr-engine

Provider-agnostic OCR recognition: an OcrEngine trait (image -> text), a LocalOcrEngine marker for on-host/no-egress engines, and zeroizing value types. Recognition ONLY — persistence lives in infrastructure-ocr, adapters in infrastructure-ocr-tesseract / infrastructure-ocr-ai.

Provider-agnostic OCR recognition: an OcrEngine trait (image -> text), a LocalOcrEngine marker for on-host/no-egress engines, and zeroizing value types. Recognition ONLY — persistence lives in infrastructure-ocr, adapters in infrastructure-ocr-tesseract / infrastructure-ocr-ai.

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/ocr-engine
Edition2021
Targetsinfrastructure_ocr_engine
Public items19 across 0 modules
Tests5

What it is for

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

This crate is recognition ONLY: the OcrEngine trait, the LocalOcrEngine marker for on-host / no-egress engines, and zeroizing value types. It holds NO adapter dependencies — Tesseract lives in infrastructure-ocr-tesseract, the AI-vision adapters in infrastructure-ocr-ai, and persistence in infrastructure-ocr (storage).

The security boundary is a TYPE, not a flag

LocalOcrEngine marks an engine that runs on-host and never transmits the image off the machine. A DLP consumer that must never exfiltrate pixels bounds its generic on E: LocalOcrEngine, so a remote engine (which impls OcrEngine but NOT LocalOcrEngine) simply cannot be constructed into it — enforced by the compiler, with no runtime opt-in to get wrong.

Sensitive output

Recognized text is as sensitive as the source image (it may be a full screenshot's worth of secrets). OcrText therefore holds its text in zeroize::Zeroizing, is not Clone/Serialize, and has a redacting Debug — it never leaks into logs, traces, or serialized payloads. Callers read it explicitly via OcrText::text.

Capabilities

LocalOcrEngine

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub trait LocalOcrEngine

MediaType

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub enum MediaType
MediaType :: fn as_str(& self) -> & 'static str
MediaType :: fn from_extension(ext : & str) -> Option <Self>

OcrEngine

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub trait OcrEngine

OcrError

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub enum OcrError

OcrInput

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub struct OcrInput<'a>

OcrInput<'_>

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
OcrInput<'_> :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result

OcrInput<'a>

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
OcrInput<'a> :: fn new(bytes : & 'a u8, media_type : MediaType, width : u32, height : u32) -> Self
OcrInput<'a> :: fn bytes(& self) -> & u8
OcrInput<'a> :: fn media_type(& self) -> MediaType
OcrInput<'a> :: fn width(& self) -> u32
OcrInput<'a> :: fn height(& self) -> u32

OcrText

infrastructure-ocr-engine — provider-agnostic OCR recognition (image → text).

Item
pub struct OcrText
OcrText :: fn new(text : impl Into <String>, confidence : Option <f32>) -> Self
OcrText :: fn text(& self) -> & str
OcrText :: fn confidence(& self) -> Option <f32>
OcrText :: fn into_text(self) -> Zeroizing <String>
OcrText :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result

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 MediaTypeEncoded-image media type handed to an OcrEngine.
MediaType :: fn as_str(& self) -> & 'static strThe MIME string (e.g
MediaType :: fn from_extension(ext : & str) -> Option <Self>Best-effort mapping from a lowercase file extension ("png", "jpg", …).
pub struct OcrInput<'a>An image submitted for recognition
OcrInput<'a> :: fn new(bytes : & 'a u8, media_type : MediaType, width : u32, height : u32) -> SelfBuild an input from encoded image bytes + its media type and pixel dimensions.
OcrInput<'a> :: fn bytes(& self) -> & u8The encoded image bytes.
OcrInput<'a> :: fn media_type(& self) -> MediaTypeThe image media type.
OcrInput<'a> :: fn width(& self) -> u32Pixel width.
OcrInput<'a> :: fn height(& self) -> u32Pixel height.
OcrInput<'_> :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result
pub struct OcrTextRecognized text plus an optional confidence in 0.0, 1.0
OcrText :: fn new(text : impl Into <String>, confidence : Option <f32>) -> SelfWrap recognized text + optional confidence.
OcrText :: fn text(& self) -> & strBorrow the recognized text.
OcrText :: fn confidence(& self) -> Option <f32>The confidence in 0.0, 1.0, if the engine reported one.
OcrText :: fn into_text(self) -> Zeroizing <String>Consume self, returning the zeroizing text buffer (still wiped on drop).
OcrText :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result
pub enum OcrErrorRecognition failure
pub trait OcrEngineA text-recognition engine: image bytes in, recognized text out
pub trait LocalOcrEngineMarker for engines that run entirely on-host and never transmit the image off the machine (e.g

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-engine
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
thiserror^2noalways
zeroize^1noalways

Development, from outside the workspace.

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

Build. None.

Depended on by. 9 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_infrastructure_acquire["infrastructure-acquire"] -->|uses| SELF
  n_infrastructure_agent["infrastructure-agent"] -->|uses| SELF
  n_infrastructure_ocr_ai["infrastructure-ocr-ai"] -->|uses| SELF
  n_infrastructure_ocr_provider["infrastructure-ocr-provider"] -->|uses| SELF
  n_infrastructure_ocr_tesseract["infrastructure-ocr-tesseract"] -->|uses| SELF
  n_operations_dlp_agent["operations-dlp-agent"] -->|uses| SELF
  n_operations_dlp_sensor["operations-dlp-sensor"] -->|uses| SELF
  n_tools_gui_harness["tools-gui-harness"] -->|uses| SELF
  n_tools_imp["tools-imp"] -->|uses| SELF
  SELF["infrastructure-ocr-engine"]
  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_engine`src/lib.rs`

Error model

Error typeNamed by
OcrErrordeclared, no public signature returns it

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.

9 workspace crates depend on this one: infrastructure-acquire, infrastructure-agent, infrastructure-ocr-ai, infrastructure-ocr-provider, infrastructure-ocr-tesseract, operations-dlp-agent, operations-dlp-sensor, tools-gui-harness, tools-imp.

Verification

KindCount
Unit tests5
Integration tests0
Examples0
Doctests0

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

ModuleTestsExamplesConsumers
crate root6036

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1719
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 17
    "No rustdoc detected" : 2

Metrics

MetricValue
Rust source files1
Source lines315
Code lines211
Public API items19
Public modules0
Tests5
Examples0
Cargo features0
Direct runtime dependencies3
Workspace reverse dependencies9
pie showData
    title Public API by kind
    "enum" : 2
    "method" : 13
    "struct" : 2
    "trait" : 2
pie showData
    title Rust source composition
    "Code" : 211
    "Blank or comment" : 104

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.

All infrastructure · Manual