Skip to main content

Module utils

Module utils 

Source

Modules§

env_secret
Env-var-with-_FILE-companion helper (PLAN.md Phase 6.4).
file_mode
Default permissions for the files RedDB creates.
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
Re-export shim: the zero-dependency in-house JSON parser now lives in reddb-io-types (ADR 0053). This module preserves every crate::utils::json::... import path so existing call-sites compile unchanged.
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§

conflicting_secret_env
The first secret that is set both inline and through its _FILE companion, if any.
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.
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.