Expand description
Stable public error messages with debug-only diagnostic detail.
redacted-error gives applications a small facade for errors that cross
crate, process, API, or protocol boundaries:
- static public messages go through
message!/message_string! - runtime diagnostic details go through
detail!, [detail], ordisplay - backend-facing behavior uses
ErrorCodeorPublicError - release
Debugoutput can delegate to redactedDisplaywithimpl_redacted_debug!
The default build uses obfstr internally for static public messages. Build
with default-features = false to use plain literals instead. The public
macros stay the same either way.
§Security
This crate is a leakage-reduction tool, not a confidentiality boundary.
-
The
obfuscatefeature only raises the bar against trivialstrings-style inspection of compiled binaries. It is not a defense against a debugger, dynamic instrumentation, symbol tables, or any motivated reverse engineer. Do not treat obfuscated literals as secret. -
Diagnostic-detail stripping is gated on
cfg(debug_assertions). That cfg is on in thedevprofile and off in the standardreleaseprofile, but Cargo lets users opt back in with[profile.release] debug-assertions = true. Under that override everydetail!/display/ [detail] call leaks runtime detail in release builds. Avoid that combination if redaction matters. -
The
detail!macro skips evaluating its format arguments in release. The [detail] anddisplayfree functions still evaluate (and drop) their argument, because the cfg branch lives inside the function body. Prefer the macro when the argument has nontrivial cost or side effects.
Macros§
- detail
- Formats runtime diagnostic detail in debug builds and strips it in release builds.
- impl_
redacted_ debug - Implements release
Debugby delegating toDisplay. - message
- Returns a public-facing message for a string literal.
- message_
string - Returns an owned public-facing message.
Structs§
- Message
- Public-facing message text.
Traits§
- Error
Code - Machine-readable code for errors that cross process or API boundaries.
- Public
Error - Stable public message for errors that cross process or API boundaries.