pub struct EncryptedSecretStore { /* private fields */ }Expand description
Encrypted secret storage for sensitive data at rest
Implementations§
Source§impl EncryptedSecretStore
impl EncryptedSecretStore
Sourcepub fn new() -> SecretResult<(Self, [u8; 32])>
pub fn new() -> SecretResult<(Self, [u8; 32])>
Create a new encrypted secret store with a random key
Sourcepub fn from_data(secrets: HashMap<String, String>, salt: String) -> Self
pub fn from_data(secrets: HashMap<String, String>, salt: String) -> Self
Create an encrypted secret store from existing data
Sourcepub fn add_secret(
&mut self,
key: &[u8; 32],
name: &str,
value: &str,
) -> SecretResult<()>
pub fn add_secret( &mut self, key: &[u8; 32], name: &str, value: &str, ) -> SecretResult<()>
Add an encrypted secret
Sourcepub fn get_secret(&self, key: &[u8; 32], name: &str) -> SecretResult<String>
pub fn get_secret(&self, key: &[u8; 32], name: &str) -> SecretResult<String>
Get and decrypt a secret
Sourcepub fn remove_secret(&mut self, name: &str) -> bool
pub fn remove_secret(&mut self, name: &str) -> bool
Remove a secret
Sourcepub fn list_secrets(&self) -> Vec<String>
pub fn list_secrets(&self) -> Vec<String>
List all secret names
Sourcepub fn has_secret(&self, name: &str) -> bool
pub fn has_secret(&self, name: &str) -> bool
Check if a secret exists
Sourcepub fn secret_count(&self) -> usize
pub fn secret_count(&self) -> usize
Get the number of stored secrets
Sourcepub fn to_json(&self) -> SecretResult<String>
pub fn to_json(&self) -> SecretResult<String>
Serialize to JSON
Sourcepub fn from_json(json: &str) -> SecretResult<Self>
pub fn from_json(json: &str) -> SecretResult<Self>
Deserialize from JSON.
Detects the old serialization format (which had a top-level nonce field)
and returns a clear error directing users to re-create their secret store.
Sourcepub async fn save_to_file(&self, path: &str) -> SecretResult<()>
pub async fn save_to_file(&self, path: &str) -> SecretResult<()>
Save to file
Sourcepub async fn load_from_file(path: &str) -> SecretResult<Self>
pub async fn load_from_file(path: &str) -> SecretResult<Self>
Load from file
Trait Implementations§
Source§impl Clone for EncryptedSecretStore
impl Clone for EncryptedSecretStore
Source§impl Debug for EncryptedSecretStore
impl Debug for EncryptedSecretStore
Source§impl Default for EncryptedSecretStore
impl Default for EncryptedSecretStore
Source§impl<'de> Deserialize<'de> for EncryptedSecretStore
impl<'de> Deserialize<'de> for EncryptedSecretStore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EncryptedSecretStore
impl RefUnwindSafe for EncryptedSecretStore
impl Send for EncryptedSecretStore
impl Sync for EncryptedSecretStore
impl Unpin for EncryptedSecretStore
impl UnsafeUnpin for EncryptedSecretStore
impl UnwindSafe for EncryptedSecretStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more