pub struct Vault { /* private fields */ }Expand description
Vault file storage.
Implementations§
Source§impl Vault
impl Vault
Sourcepub fn new(
id: VaultId,
name: String,
cipher: Cipher,
kdf: KeyDerivation,
flags: VaultFlags,
) -> Self
pub fn new( id: VaultId, name: String, cipher: Cipher, kdf: KeyDerivation, flags: VaultFlags, ) -> Self
Create a new vault.
Shared access.
Sourcepub fn deriver(&self) -> Box<dyn Deriver<Sha256> + Send + 'static>
pub fn deriver(&self) -> Box<dyn Deriver<Sha256> + Send + 'static>
Key derivation function deriver.
Sourcepub fn set_default_flag(&mut self, value: bool)
pub fn set_default_flag(&mut self, value: bool)
Set whether this vault is a default vault.
Sourcepub fn set_archive_flag(&mut self, value: bool)
pub fn set_archive_flag(&mut self, value: bool)
Set whether this vault is an archive vault.
Sourcepub fn set_authenticator_flag(&mut self, value: bool)
pub fn set_authenticator_flag(&mut self, value: bool)
Set whether this vault is an authenticator vault.
Sourcepub fn set_contact_flag(&mut self, value: bool)
pub fn set_contact_flag(&mut self, value: bool)
Set whether this vault is for contacts.
Sourcepub fn set_system_flag(&mut self, value: bool)
pub fn set_system_flag(&mut self, value: bool)
Set whether this vault is for system specific information.
Sourcepub fn set_device_flag(&mut self, value: bool)
pub fn set_device_flag(&mut self, value: bool)
Set whether this vault is for device specific information.
Sourcepub fn set_no_sync_flag(&mut self, value: bool)
pub fn set_no_sync_flag(&mut self, value: bool)
Set whether this vault should not sync with own devices.
Sourcepub fn insert_entry(&mut self, id: SecretId, entry: VaultCommit)
pub fn insert_entry(&mut self, id: SecretId, entry: VaultCommit)
Insert a secret into this vault.
Sourcepub fn get(&self, id: &SecretId) -> Option<&VaultCommit>
pub fn get(&self, id: &SecretId) -> Option<&VaultCommit>
Get a secret in this vault.
Sourcepub async fn encrypt(
&self,
key: &PrivateKey,
plaintext: &[u8],
) -> Result<AeadPack, Error>
pub async fn encrypt( &self, key: &PrivateKey, plaintext: &[u8], ) -> Result<AeadPack, Error>
Encrypt plaintext using the cipher assigned to this vault.
Sourcepub async fn decrypt(
&self,
key: &PrivateKey,
aead: &AeadPack,
) -> Result<Vec<u8>, Error>
pub async fn decrypt( &self, key: &PrivateKey, aead: &AeadPack, ) -> Result<Vec<u8>, Error>
Decrypt ciphertext using the cipher assigned to this vault.
Sourcepub fn rotate_identifier(&mut self)
pub fn rotate_identifier(&mut self)
Choose a new identifier for this vault.
This is useful when importing a vault and the identifier collides with an existing vault; rather than overwriting the existing vault we can import it alongside by choosing a new identifier.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Uuid, &VaultCommit)>
pub fn iter(&self) -> impl Iterator<Item = (&Uuid, &VaultCommit)>
Iterator for the secret keys and values.
Sourcepub fn values(&self) -> impl Iterator<Item = &VaultCommit>
pub fn values(&self) -> impl Iterator<Item = &VaultCommit>
Iterator for the secret values.
Sourcepub async fn into_event(&self) -> Result<WriteEvent, Error>
pub async fn into_event(&self) -> Result<WriteEvent, Error>
Convert this vault into a create vault event.
Ensures the vault is head-only before encoding into the event.
Sourcepub fn commits(&self) -> impl Iterator<Item = (&Uuid, &CommitHash)>
pub fn commits(&self) -> impl Iterator<Item = (&Uuid, &CommitHash)>
Iterator for the secret keys and commit hashes.
Sourcepub fn flags(&self) -> &VaultFlags
pub fn flags(&self) -> &VaultFlags
Reference to the vault flags.
Sourcepub fn flags_mut(&mut self) -> &mut VaultFlags
pub fn flags_mut(&mut self) -> &mut VaultFlags
Mutable reference to the vault flags.
Sourcepub fn kdf(&self) -> &KeyDerivation
pub fn kdf(&self) -> &KeyDerivation
Key derivation function.
Sourcepub fn header_mut(&mut self) -> &mut Header
pub fn header_mut(&mut self) -> &mut Header
Mutable vault header.
Sourcepub fn data(&self) -> &IndexMap<SecretId, VaultCommit>
pub fn data(&self) -> &IndexMap<SecretId, VaultCommit>
Vault data.
Sourcepub fn data_mut(&mut self) -> &mut IndexMap<SecretId, VaultCommit>
pub fn data_mut(&mut self) -> &mut IndexMap<SecretId, VaultCommit>
Mutable vault data.
Trait Implementations§
Source§impl Decodable for Vault
impl Decodable for Vault
Source§impl<'de> Deserialize<'de> for Vault
impl<'de> Deserialize<'de> for Vault
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>,
Source§impl Encodable for Vault
impl Encodable for Vault
Source§fn encode<'life0, 'life1, 'async_trait, W>(
&'life0 self,
writer: &'life1 mut BinaryWriter<W>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
W: 'async_trait + AsyncWrite + AsyncSeek + Unpin + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn encode<'life0, 'life1, 'async_trait, W>(
&'life0 self,
writer: &'life1 mut BinaryWriter<W>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
W: 'async_trait + AsyncWrite + AsyncSeek + Unpin + Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl EncryptedEntry for Vault
impl EncryptedEntry for Vault
Source§fn summary<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Summary, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn summary<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Summary, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn vault_name<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn vault_name<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Cow<'_, str>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set_vault_name<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_vault_name<'life0, 'async_trait>(
&'life0 mut self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set_vault_flags<'life0, 'async_trait>(
&'life0 mut self,
flags: VaultFlags,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_vault_flags<'life0, 'async_trait>(
&'life0 mut self,
flags: VaultFlags,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set_vault_meta<'life0, 'async_trait>(
&'life0 mut self,
meta_data: AeadPack,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_vault_meta<'life0, 'async_trait>(
&'life0 mut self,
meta_data: AeadPack,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn create_secret<'life0, 'async_trait>(
&'life0 mut self,
commit: CommitHash,
secret: VaultEntry,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_secret<'life0, 'async_trait>(
&'life0 mut self,
commit: CommitHash,
secret: VaultEntry,
) -> Pin<Box<dyn Future<Output = Result<WriteEvent, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn read_secret<'a, 'life0, 'async_trait>(
&'a self,
id: &'life0 SecretId,
) -> Pin<Box<dyn Future<Output = Result<Option<(Cow<'a, VaultCommit>, ReadEvent)>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn read_secret<'a, 'life0, 'async_trait>(
&'a self,
id: &'life0 SecretId,
) -> Pin<Box<dyn Future<Output = Result<Option<(Cow<'a, VaultCommit>, ReadEvent)>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Source§fn update_secret<'life0, 'life1, 'async_trait>(
&'life0 mut self,
id: &'life1 SecretId,
commit: CommitHash,
secret: VaultEntry,
) -> Pin<Box<dyn Future<Output = Result<Option<WriteEvent>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_secret<'life0, 'life1, 'async_trait>(
&'life0 mut self,
id: &'life1 SecretId,
commit: CommitHash,
secret: VaultEntry,
) -> Pin<Box<dyn Future<Output = Result<Option<WriteEvent>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl<E> From<AccessPoint<E>> for Vault
impl<E> From<AccessPoint<E>> for Vault
Source§fn from(value: AccessPoint<E>) -> Self
fn from(value: AccessPoint<E>) -> Self
Source§impl<E> From<Vault> for AccessPoint<E>
impl<E> From<Vault> for AccessPoint<E>
Source§impl IntoIterator for Vault
impl IntoIterator for Vault
impl Eq for Vault
impl StructuralPartialEq for Vault
Auto Trait Implementations§
impl Freeze for Vault
impl RefUnwindSafe for Vault
impl Send for Vault
impl Sync for Vault
impl Unpin for Vault
impl UnwindSafe for Vault
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.