pub struct Sensitive<T> { /* private fields */ }Expand description
Wraps a secret so Debug and Display always render "[REDACTED]"
while the value stays usable through Sensitive::expose.
Deliberately attribute-free: no derive macros, so nothing can
accidentally drift into leaking. The redacting impls carry no T: Debug/T: Display bound, which means a container’s derived Debug
also renders "[REDACTED]" for the field — the value cannot escape
through any formatting path.
Deserialization is always supported (loading configuration is the
point). Serialization is opt-in behind the serde feature, because
serializing secrets invites accidental disclosure — enable it only when
your pipeline genuinely needs to write the value back out. Every
intentional read goes through expose, which makes
secret usage grep-friendly: grep -rn '\.expose()' audits every
touchpoint.
§Example
use config_kit::Sensitive;
let token = Sensitive::new("hunter2".to_owned());
assert_eq!(format!("{token:?}"), "[REDACTED]");
assert_eq!(format!("{token}"), "[REDACTED]");
assert_eq!(token.expose(), "hunter2");