pub struct Vault { /* private fields */ }Expand description
An open vault. Holds the decrypted contents in memory and the master passphrase needed to re-encrypt on save. Drop does not persist.
Implementations§
Source§impl Vault
impl Vault
Sourcepub fn open(
path: impl Into<PathBuf>,
passphrase: impl Into<String>,
) -> Result<Self>
pub fn open( path: impl Into<PathBuf>, passphrase: impl Into<String>, ) -> Result<Self>
Open an existing vault file with the master passphrase. Decrypts the contents INTO MEMORY.
Sourcepub fn init(
path: impl Into<PathBuf>,
passphrase: impl Into<String>,
) -> Result<Self>
pub fn init( path: impl Into<PathBuf>, passphrase: impl Into<String>, ) -> Result<Self>
Create a new empty vault. Errors if a file already exists at path.
Sourcepub fn init_force(
path: impl Into<PathBuf>,
passphrase: impl Into<String>,
) -> Result<Self>
pub fn init_force( path: impl Into<PathBuf>, passphrase: impl Into<String>, ) -> Result<Self>
Create a new empty vault, overwriting any existing file.
pub fn path(&self) -> &Path
Sourcepub fn index(&self) -> Vec<ItemRef>
pub fn index(&self) -> Vec<ItemRef>
The content index: namespace + name + protection for every item, without exposing sealed plaintext.
Sourcepub fn put_document(
&mut self,
namespace: &str,
name: &str,
bytes: Vec<u8>,
) -> Result<()>
pub fn put_document( &mut self, namespace: &str, name: &str, bytes: Vec<u8>, ) -> Result<()>
Store a master-tier document (config / metadata / state). Upserts by (namespace, name) and persists.
Sourcepub fn get_document(&self, namespace: &str, name: &str) -> Option<&[u8]>
pub fn get_document(&self, namespace: &str, name: &str) -> Option<&[u8]>
Read a master-tier document’s bytes. None if absent or sealed.
Sourcepub fn seal_document(
&mut self,
namespace: &str,
name: &str,
bytes: &[u8],
credential: &str,
) -> Result<()>
pub fn seal_document( &mut self, namespace: &str, name: &str, bytes: &[u8], credential: &str, ) -> Result<()>
Store a document sealed under an INDEPENDENT credential. Upserts.
Sourcepub fn open_document(
&self,
namespace: &str,
name: &str,
credential: &str,
) -> Result<Zeroizing<Vec<u8>>>
pub fn open_document( &self, namespace: &str, name: &str, credential: &str, ) -> Result<Zeroizing<Vec<u8>>>
Open a document INTO MEMORY. For a sealed document, credential is its
independent secret. Returns a zeroizing buffer; nothing touches disk.
pub fn remove_document(&mut self, namespace: &str, name: &str) -> Result<()>
Sourcepub fn put_subvault(
&mut self,
namespace: &str,
name: &str,
sub: &VaultContents,
credential: &str,
) -> Result<()>
pub fn put_subvault( &mut self, namespace: &str, name: &str, sub: &VaultContents, credential: &str, ) -> Result<()>
Store a nested vault, sealed under its own credential (recursion).
Sourcepub fn open_subvault(
&self,
namespace: &str,
name: &str,
credential: &str,
) -> Result<VaultContents>
pub fn open_subvault( &self, namespace: &str, name: &str, credential: &str, ) -> Result<VaultContents>
Open a nested vault into memory with its credential.