Skip to main content

Vault

Struct Vault 

Source
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

Source

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.

Source

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.

Source

pub fn init_force( path: impl Into<PathBuf>, passphrase: impl Into<String>, ) -> Result<Self>

Create a new empty vault, overwriting any existing file.

Source

pub fn path(&self) -> &Path

Source

pub fn index(&self) -> Vec<ItemRef>

The content index: namespace + name + protection for every item, without exposing sealed plaintext.

Source

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.

Source

pub fn get_document(&self, namespace: &str, name: &str) -> Option<&[u8]>

Read a master-tier document’s bytes. None if absent or sealed.

Source

pub fn seal_document( &mut self, namespace: &str, name: &str, bytes: &[u8], credential: &str, ) -> Result<()>

Store a document sealed under an INDEPENDENT credential. Upserts.

Source

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.

Source

pub fn remove_document(&mut self, namespace: &str, name: &str) -> Result<()>

Source

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).

Source

pub fn open_subvault( &self, namespace: &str, name: &str, credential: &str, ) -> Result<VaultContents>

Open a nested vault into memory with its credential.

Auto Trait Implementations§

§

impl Freeze for Vault

§

impl RefUnwindSafe for Vault

§

impl Send for Vault

§

impl Sync for Vault

§

impl Unpin for Vault

§

impl UnsafeUnpin for Vault

§

impl UnwindSafe for Vault

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V