Skip to main content

SecretString

Type Alias SecretString 

Source
pub type SecretString = Secret<String>;
Expand description

String-backed secret value.

Aliased Type§

pub struct SecretString { /* private fields */ }

Implementations§

Source§

impl SecretString

Source

pub fn from_string(value: impl Into<String>) -> Self

Creates a string-backed secret from any string-like value.

Examples found in repository?
examples/secret_basic.rs (line 5)
3fn main() {
4    let api_key = Secret::new("rk_live_example");
5    let password = SecretString::from_string("correct horse battery staple");
6
7    println!("api key: {api_key}");
8    println!("password: {password:?}");
9    println!("api key length: {}", api_key.expose_secret().len());
10}
Source

pub fn expose_str(&self) -> &str

Returns the secret as str.