Expand description
Environment-variable helpers shared by every crate in the workspace.
The knobs documented in the README (DOCLING_RS_*, DOCLING_*) grew one
hand-rolled std::env::var dance per call site — presence checks that
treated FOO=0 as on, three copies of the same truthiness predicate,
a dozen .ok().and_then(|v| v.parse().ok()) chains. This module is the
single vocabulary for all of them:
flag— boolean knobs (DOCLING_RS_FP32=1);nonempty— string knobs where a blank value means “unset”;parse— numeric knobs with a coded default;debug_enabled/crate::debug_log!— theDOCLING_RS_DEBUGdiagnostics channel.
On targets without an environment (wasm32-unknown-unknown) std::env::var
reports “not present”, so every helper falls back to its default — the
wasm builds keep compiling with no cfg noise at the call sites.
Functions§
- debug_
enabled - Whether
DOCLING_RS_DEBUGdiagnostics are on. Cached on first use: the callers sit inside per-page pipeline loops, and a process does not meaningfully flip its own debug env mid-run. - flag
- True when
keyis set to a truthy value. Truthy is anything except the explicit “off” spellings — empty,0,false,no,off(trimmed, ASCII case-insensitive) — so bothFOO=1andFOO=yesenable, andFOO=0actually disables instead of counting as “present, therefore on” (the trap the oldenv::var(..).is_ok()checks all shared). - nonempty
- The trimmed value of
key, if set and non-blank. TheOptionshape makes “env override, else default” read asnonempty(K).unwrap_or_else(..)and composes with.or_elsechains for multi-variable fallbacks. - parse
keyparsed asT, if set and parseable. Unparseable values fall back to the coded default silently — tuning knobs degrade, they don’t error.