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.
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/ocr-engine |
| Edition | 2021 |
| Targets | infrastructure_ocr_engine |
| Public items | 19 across 0 modules |
| Tests | 5 |
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`
| Item | What it is |
|---|---|
pub enum MediaType | Encoded-image media type handed to an OcrEngine. |
MediaType :: fn as_str(& self) -> & 'static str | The 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) -> Self | Build an input from encoded image bytes + its media type and pixel dimensions. |
OcrInput<'a> :: fn bytes(& self) -> & u8 | The encoded image bytes. |
OcrInput<'a> :: fn media_type(& self) -> MediaType | The image media type. |
OcrInput<'a> :: fn width(& self) -> u32 | Pixel width. |
OcrInput<'a> :: fn height(& self) -> u32 | Pixel height. |
OcrInput<'_> :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result | — |
pub struct OcrText | Recognized text plus an optional confidence in 0.0, 1.0 |
OcrText :: fn new(text : impl Into <String>, confidence : Option <f32>) -> Self | Wrap recognized text + optional confidence. |
OcrText :: fn text(& self) -> & str | Borrow 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 OcrError | Recognition failure |
pub trait OcrEngine | A text-recognition engine: image bytes in, recognized text out |
pub trait LocalOcrEngine | Marker 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) |
| Location | crates/infrastructure/ocr-engine |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
thiserror | ^2 | — | no | always |
zeroize | ^1 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full, macros, rt-multi-thread | no | always |
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
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_ocr_engine | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
OcrError | declared, no public signature returns it |
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
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
| Kind | Count |
|---|---|
| Unit tests | 5 |
| 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 | 6 | 0 | 36 |
What the tests establish, by name:
error_display_carries_no_text—src/lib.rslocal_engine_satisfies_the_local_bound_and_recognizes—src/lib.rsmedia_type_mime_and_extension_roundtrip—src/lib.rsocr_input_exposes_fields_and_redacts_bytes_in_debug—src/lib.rsocr_text_exposes_text_but_debug_redacts_it—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 17 | 19 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 17
"No rustdoc detected" : 2
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 315 |
| Code lines | 211 |
| Public API items | 19 |
| Public modules | 0 |
| Tests | 5 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 9 |
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.