Skip to main content

loong_contracts/
secret_value.rs

1use zeroize::Zeroize;
2
3pub struct SecretValue {
4    inner: String,
5}
6
7impl SecretValue {
8    pub fn new(inner: String) -> Self {
9        Self { inner }
10    }
11
12    pub fn expose(&self) -> &str {
13        self.inner.as_str()
14    }
15
16    pub fn into_inner(mut self) -> String {
17        std::mem::take(&mut self.inner)
18    }
19}
20
21impl Drop for SecretValue {
22    fn drop(&mut self) {
23        self.inner.zeroize();
24    }
25}