reliakit-secret
Secret-safe wrappers for Rust values that should not leak through formatting or diagnostics.
reliakit-secret provides Secret<T>, a small wrapper that redacts its inner
value in Debug and Display output. Access to the wrapped value is explicit
through ExposeSecret.
The crate has no dependencies and forbids unsafe code.
What This Crate Does
This crate helps prevent accidental secret leaks in logs, error messages, debug output, and diagnostic reports.
Instead of passing a raw password, token, or API key through a public API, wrap it
as a Secret<T>:
use ;
What This Crate Does Not Do
This crate does not provide memory zeroization, encryption, process isolation, or protection against memory inspection. It is a formatting and diagnostics safety primitive.
Installation
[]
= "0.1"
For no_std without allocation:
[]
= { = "0.1", = false }
For no_std with string-backed secrets:
[]
= { = "0.1", = false, = ["alloc"] }
Examples
Generic secret
use ;
let token = new;
assert_eq!;
assert_eq!;
assert_eq!;
String-backed secret
use ;
let password = from_string;
assert_eq!;
assert_eq!;
assert_eq!;
Consuming a secret
use Secret;
let secret = new;
let token = secret.into_inner;
assert_eq!;
Available Types
| Type | Description |
|---|---|
Secret<T> |
Generic wrapper that redacts Debug and Display |
SecretString |
String-backed secret, available with std or alloc |
ExposeSecret<T> |
Trait for explicit shared access |
ExposeSecretMut<T> |
Trait for explicit mutable access |
Feature Flags
| Flag | Default | Description |
|---|---|---|
std |
yes | Enables the standard library |
alloc |
no | Enables SecretString without std |
no_std
The crate supports no_std.
Generic Secret<T> works without allocation. SecretString requires alloc or
std.
Safety
This crate is #![forbid(unsafe_code)].
Minimum Supported Rust Version
Rust 1.85 and newer. No nightly features are used.
Status
Active. The crate is intentionally small and focused on formatting-safe secret wrappers.
License
Licensed under the MIT License.