Vault

Struct Vault 

Source
pub struct Vault { /* private fields */ }
Expand description

Vault file storage.

Implementations§

Source§

impl Vault

Source

pub fn new( id: VaultId, name: String, cipher: Cipher, kdf: KeyDerivation, flags: VaultFlags, ) -> Self

Create a new vault.

Source

pub fn shared_access(&self) -> &SharedAccess

Shared access.

Source

pub fn vault_urn(id: &VaultId) -> Result<Urn, Error>

Get the URN for a vault identifier.

Source

pub fn deriver(&self) -> Box<dyn Deriver<Sha256> + Send + 'static>

Key derivation function deriver.

Source

pub fn set_default_flag(&mut self, value: bool)

Set whether this vault is a default vault.

Source

pub fn set_archive_flag(&mut self, value: bool)

Set whether this vault is an archive vault.

Source

pub fn set_authenticator_flag(&mut self, value: bool)

Set whether this vault is an authenticator vault.

Source

pub fn set_contact_flag(&mut self, value: bool)

Set whether this vault is for contacts.

Source

pub fn set_system_flag(&mut self, value: bool)

Set whether this vault is for system specific information.

Source

pub fn set_device_flag(&mut self, value: bool)

Set whether this vault is for device specific information.

Source

pub fn set_no_sync_flag(&mut self, value: bool)

Set whether this vault should not sync with own devices.

Source

pub fn insert_entry(&mut self, id: SecretId, entry: VaultCommit)

Insert a secret into this vault.

Source

pub fn get(&self, id: &SecretId) -> Option<&VaultCommit>

Get a secret in this vault.

Source

pub async fn encrypt( &self, key: &PrivateKey, plaintext: &[u8], ) -> Result<AeadPack, Error>

Encrypt plaintext using the cipher assigned to this vault.

Source

pub async fn decrypt( &self, key: &PrivateKey, aead: &AeadPack, ) -> Result<Vec<u8>, Error>

Decrypt ciphertext using the cipher assigned to this vault.

Source

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.

Source

pub async fn verify(&self, key: &AccessKey) -> Result<(), Error>

Verify an access key.

Source

pub fn iter(&self) -> impl Iterator<Item = (&Uuid, &VaultCommit)>

Iterator for the secret keys and values.

Source

pub fn keys(&self) -> impl Iterator<Item = &Uuid>

Iterator for the secret keys.

Source

pub fn values(&self) -> impl Iterator<Item = &VaultCommit>

Iterator for the secret values.

Source

pub fn len(&self) -> usize

Number of secrets in this vault.

Source

pub fn is_empty(&self) -> bool

Determine if this vault is empty.

Source

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.

Source

pub fn commits(&self) -> impl Iterator<Item = (&Uuid, &CommitHash)>

Iterator for the secret keys and commit hashes.

Source

pub fn salt(&self) -> Option<&String>

Get the salt used for passphrase authentication.

Source

pub fn seed(&self) -> Option<&Seed>

Get the seed used for passphrase authentication.

Source

pub fn summary(&self) -> &Summary

Get the summary for this vault.

Source

pub fn flags(&self) -> &VaultFlags

Reference to the vault flags.

Source

pub fn flags_mut(&mut self) -> &mut VaultFlags

Mutable reference to the vault flags.

Source

pub fn id(&self) -> &VaultId

Unique identifier for this vault.

Source

pub fn name(&self) -> &str

Public name for this vault.

Source

pub fn set_name(&mut self, name: String)

Set the public name of this vault.

Source

pub fn cipher(&self) -> &Cipher

Encryption cipher for this vault.

Source

pub fn kdf(&self) -> &KeyDerivation

Key derivation function.

Source

pub fn header(&self) -> &Header

Vault header.

Source

pub fn header_mut(&mut self) -> &mut Header

Mutable vault header.

Source

pub fn data(&self) -> &IndexMap<SecretId, VaultCommit>

Vault data.

Source

pub fn data_mut(&mut self) -> &mut IndexMap<SecretId, VaultCommit>

Mutable vault data.

Source

pub fn meta_data(&self) -> HashMap<&Uuid, &AeadPack>

Get the meta data for all the secrets.

Trait Implementations§

Source§

impl Clone for Vault

Source§

fn clone(&self) -> Vault

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Vault

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decodable for Vault

Source§

fn decode<'life0, 'life1, 'async_trait, R>( &'life0 mut self, reader: &'life1 mut BinaryReader<R>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where R: 'async_trait + AsyncRead + AsyncSeek + Unpin + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Decode from the binary reader into self.
Source§

impl Default for Vault

Source§

fn default() -> Vault

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Vault

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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,

Encode self into the binary writer.
Source§

impl EncryptedEntry for Vault

Source§

type Error = Error

Error type for vault access.
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,

Get the vault summary.
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,

Get the name of a vault.
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,

Set the name of a vault.
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,

Set the flags for a vault.
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,

Set the vault meta data.
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,

Add an encrypted secret to the vault.
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,

Get an encrypted secret from the vault.
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,

Update an encrypted secret in the vault.
Source§

fn delete_secret<'life0, 'life1, 'async_trait>( &'life0 mut self, id: &'life1 SecretId, ) -> Pin<Box<dyn Future<Output = Result<Option<WriteEvent>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove an encrypted secret from the vault.
Source§

fn replace_vault<'life0, 'life1, 'async_trait>( &'life0 mut self, vault: &'life1 Vault, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Replace the vault with new vault content.
Source§

impl<E> From<AccessPoint<E>> for Vault
where E: Error + Debug + From<Error> + From<Error> + From<Error> + Send + Sync + 'static,

Source§

fn from(value: AccessPoint<E>) -> Self

Converts to this type from the input type.
Source§

impl From<Header> for Vault

Source§

fn from(header: Header) -> Self

Converts to this type from the input type.
Source§

impl From<Summary> for Vault

Source§

fn from(value: Summary) -> Self

Converts to this type from the input type.
Source§

impl<E> From<Vault> for AccessPoint<E>
where E: Error + Debug + From<Error> + From<Error> + From<Error> + Send + Sync + 'static,

Source§

fn from(value: Vault) -> Self

Converts to this type from the input type.
Source§

impl From<Vault> for Header

Source§

fn from(value: Vault) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for Vault

Source§

type Item = (Uuid, VaultCommit)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Uuid, VaultCommit>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Vault

Source§

fn eq(&self, other: &Vault) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Vault

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Vault

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,