1use secrecy::{ExposeSecret, SecretString};
2
3pub struct SecretValue {
4 value: SecretString,
5}
6
7impl SecretValue {
8 pub fn new(value: String) -> Self {
9 Self {
10 value: SecretString::from(value),
11 }
12 }
13
14 pub fn expose(&self) -> &str {
15 self.value.expose_secret()
16 }
17}
18
19#[cfg(test)]
20mod tests {
21 use super::*;
22
23 #[test]
24 fn exposes_secret_value_when_explicitly_requested() {
25 let secret = SecretValue::new("secret-token".to_owned());
26
27 assert_eq!(secret.expose(), "secret-token");
28 }
29}