pub type SecureString = SecretString;Expand description
A secure string that automatically zeros its memory on drop.
This is a type alias for secrecy::SecretString, which provides:
- Automatic memory zeroing on drop
- Prevention of accidental logging via Debug/Display
- Industry-standard security practices
§Security
The contained data is automatically zeroed when the value is dropped,
using the zeroize crate which provides compiler-fence-backed guarantees
that the zeroing operation won’t be optimized away.
§Usage
Access the underlying string using .expose_secret():
use api_keys_simplified::SecureString;
use api_keys_simplified::ExposeSecret;
let secret = SecureString::from("my_secret".to_string());
let value: &str = secret.expose_secret();§Design: Why No Deref<Target=str>?
This type intentionally does NOT implement Deref to maintain security:
- Explicit access: Requires
.expose_secret()call, making code auditable - Prevents silent leakage: No implicit coercion to
&strin logs/errors - Grep-able security: Easy to audit with
git grep "\.expose_secret\(\)" - **Industry stan
dard**: Uses the battle-testedsecrecy` crate
Aliased Type§
pub struct SecureString { /* private fields */ }