infrastructure tier

infrastructure-ocr-tesseract

Local Tesseract OCR engine for infrastructure-ocr-engine: a subprocess adapter that pipes the image via stdin->stdout (NO temp file, no C linking), with an allowlisted binary, timeout, and input cap. Implements LocalOcrEngine (on-host, no egress) — usable on the DLP path.

Local Tesseract OCR engine for infrastructure-ocr-engine: a subprocess adapter that pipes the image via stdin->stdout (NO temp file, no C linking), with an allowlisted binary, timeout, and input cap. Implements LocalOcrEngine (on-host, no egress) — usable on the DLP path.

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/ocr-tesseract
Edition2021
Targetsocr_file, infrastructure_ocr_tesseract
Public items13 across 0 modules
Tests4

What it is for

infrastructure-ocr-tesseract — a local Tesseract OCR engine for infrastructure_ocr_engine.

It shells out to the system tesseract binary as a subprocess, piping the image in via stdin and reading text back from stdout (tesseract stdin stdout). Consequences that matter for DLP:

The binary is invoked as a strict argument vector (never a shell), from an allowlisted/configurable path, under a timeout and an input-size cap (PROCESS §17). It implements LocalOcrEngine — it runs entirely on-host and never transmits the image off the machine — so it is usable on the DLP screen path.

Capabilities

crate root

infrastructure-ocr-tesseract — a local Tesseract

Item
pub const DEFAULT_MAX_INPUT_BYTES: usize
pub const DEFAULT_TIMEOUT: Duration

TesseractEngine

infrastructure-ocr-tesseract — a local Tesseract

Item
pub struct TesseractEngine
TesseractEngine :: fn default() -> Self
TesseractEngine :: fn new() -> Self
TesseractEngine :: fn with_bin(mut self, bin : impl Into <String>) -> Self
TesseractEngine :: fn with_lang(mut self, lang : impl Into <String>) -> Self
TesseractEngine :: fn with_psm(mut self, psm : u8) -> Self
TesseractEngine :: fn with_timeout(mut self, timeout : Duration) -> Self
TesseractEngine :: fn with_max_input_bytes(mut self, max : usize) -> Self
TesseractEngine :: fn provider_id(& self) -> & 'static str
TesseractEngine :: fn is_available(& self) -> bool
TesseractEngine :: async fn recognize(& self, input : & OcrInput <'_>) -> Result <OcrText, OcrError>

How to use it

From `examples/ocr_file.rs`:


use infrastructure_ocr_engine::{MediaType, OcrEngine, OcrInput};
use infrastructure_ocr_tesseract::TesseractEngine;

#[tokio::main]
async fn main() {
    let path = std::env::args()
        .nth(1)
        .expect("usage: ocr_file <image-path>");
    let bytes = std::fs::read(&path).expect("read image");
    let media = std::path::Path::new(&path)
        .extension()
        .and_then(|e| e.to_str())
        .and_then(MediaType::from_extension)
        .unwrap_or(MediaType::Png);

    let engine = TesseractEngine::new();
    assert!(engine.is_available(), "tesseract binary not found");

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const DEFAULT_MAX_INPUT_BYTES: usizeDefault cap on the encoded image handed to Tesseract (16 MiB).
pub const DEFAULT_TIMEOUT: DurationDefault recognition timeout.
pub struct TesseractEngineA local Tesseract OCR engine (subprocess adapter).
TesseractEngine :: fn default() -> Self
TesseractEngine :: fn new() -> SelfA Tesseract engine with defaults (bin="tesseract", lang="eng", psm=6).
TesseractEngine :: fn with_bin(mut self, bin : impl Into <String>) -> SelfOverride the binary path (allowlisted/configurable; still invoked as an arg vector, never a shell).
TesseractEngine :: fn with_lang(mut self, lang : impl Into <String>) -> SelfOverride the language(s) passed to -l (e.g
TesseractEngine :: fn with_psm(mut self, psm : u8) -> SelfOverride the page-segmentation mode (--psm).
TesseractEngine :: fn with_timeout(mut self, timeout : Duration) -> SelfOverride the recognition timeout.
TesseractEngine :: fn with_max_input_bytes(mut self, max : usize) -> SelfOverride the maximum accepted encoded-image size (bytes).
TesseractEngine :: fn provider_id(& self) -> & 'static str
TesseractEngine :: fn is_available(& self) -> boolTrue iff the configured binary runs (tesseract --version exits 0).
TesseractEngine :: async fn recognize(& self, input : & OcrInput <'_>) -> Result <OcrText, OcrError>

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

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`infrastructure-ocr-engine`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
tokio^1full, process, io-util, time, rtnoalways

Development, in this workspace.

CrateTierOptionalOnly on
`infrastructure-dlp-detect`infrastructurenoalways

Development, from outside the workspace.

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

Build. None.

Depended on by. 6 workspace crates.

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

flowchart LR
  n_infrastructure_acquire["infrastructure-acquire"] -->|uses| SELF
  n_infrastructure_ocr_provider["infrastructure-ocr-provider"] -->|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-tesseract"]
  SELF -->|development| n_infrastructure_dlp_detect["infrastructure-dlp-detect"]
  SELF -->|runtime| n_infrastructure_ocr_engine["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
exampleocr_file`examples/ocr_file.rs`
libinfrastructure_ocr_tesseract`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
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.

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

Verification

KindCount
Unit tests4
Integration tests0
Examples1
Doctests0

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

ModuleTestsExamplesConsumers
crate root315

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1013
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 10
    "No rustdoc detected" : 3

Metrics

MetricValue
Rust source files1
Source lines242
Code lines176
Public API items13
Public modules0
Tests4
Examples1
Cargo features0
Direct runtime dependencies3
Workspace reverse dependencies6
pie showData
    title Public API by kind
    "constant" : 2
    "method" : 10
    "struct" : 1
pie showData
    title Rust source composition
    "Code" : 176
    "Blank or comment" : 66

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