Skip to main content

Module utils

Module utils 

Source

Modules§

env_secret
Env-var-with-_FILE-companion helper (PLAN.md Phase 6.4).
hex
Tiny hex encoder used wherever a byte slice needs to be rendered as a hex string. Centralised so the same bytes.iter().map(|b| format!("{:02x}", b)).collect() doesn’t get re-typed across the crate.
json
Minimal JSON parser and serializer with zero dependencies. Implements a subset of JSON sufficient for MCP message handling.
secret_file
*_FILE env-var expansion for containerised secret mounts.
time
Time helpers used across the engine. Centralised so the same SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default() incantation doesn’t get re-typed at 20+ call sites.

Functions§

env_with_file_fallback
Read name from the env. If unset/empty, fall back to <name>_FILE. Returns None when neither produces a usable value. Trims trailing whitespace from file contents.
expand_all_reddb_secrets
Apply expand_file_env to every standard RedDB secret env var.
expand_file_env
Read the _FILE companion of name (if set), validate, place its contents in name, and remove the _FILE var from the environment.
now_unix_millis
Current wall-clock unix milliseconds. 0 if the system clock is before the epoch (impossible on real hardware, but the API returns a Result so we degrade gracefully instead of panicking).
now_unix_nanos
Current wall-clock unix nanoseconds.
now_unix_secs
Current wall-clock unix seconds.
to_hex
Encode bytes as a lowercase hex string.
to_hex_prefix
Encode the first n bytes (or fewer) as lowercase hex. Useful for short identifiers like bearer:<sha256-prefix> labels.