Struct DbView

Source
pub struct DbView<P: BoxProvider> {
    pub vaults: HashMap<VaultId, Vault<P>>,
}
Expand description

A view over the data inside of a collection of Vault types.

Fields§

§vaults: HashMap<VaultId, Vault<P>>

A hashmap of the Vault types.

Implementations§

Source§

impl<P: BoxProvider> DbView<P>

Source

pub fn new() -> DbView<P>

Create a new DbView to interface with the Vault types in the database.

Source

pub fn init_vault(&mut self, key: &Key<P>, vid: VaultId)

Initialize a new Vault if it doesn’t exist.

Source

pub fn write( &mut self, key: &Key<P>, vid: VaultId, rid: RecordId, data: &[u8], record_hint: RecordHint, ) -> Result<(), RecordError<P::Error>>

Write a new record to a Vault. Will instead update a Record if it already exists.

Source

pub fn list_hints_and_ids( &self, key: &Key<P>, vid: VaultId, ) -> Vec<(RecordId, RecordHint)>

Lists all of the RecordHint values and RecordId values for the given Vault.

Source

pub fn contains_vault(&self, vid: &VaultId) -> bool

Check to see if a vault with the given VaultId is present.

Source

pub fn contains_record(&self, vid: VaultId, rid: RecordId) -> bool

Check to see if a Vault contains a Record through the given RecordId.

Source

pub fn get_blob_id( &self, key: &Key<P>, vid: VaultId, rid: RecordId, ) -> Result<BlobId, VaultError<P::Error>>

Get the BlobId of the blob stored in the specified Record. The BlobId changes each time the record’s content is updated.

Source

pub fn get_guard<T, E, F>( &self, key: &Key<P>, vid: VaultId, rid: RecordId, f: F, ) -> Result<T, VaultError<P::Error, E>>
where F: FnOnce(Buffer<u8>) -> Result<T, E>, E: Debug,

Get access the decrypted Buffer of the specified Record.

Source

pub fn get_guards<T, E, F, const N: usize>( &self, ids: [(Key<P>, VaultId, RecordId); N], f: F, ) -> Result<T, VaultError<P::Error, E>>
where F: FnOnce([Buffer<u8>; N]) -> Result<T, E>, E: Debug,

Source

pub fn exec_procedure<T, E, F, const N: usize>( &mut self, sources: [(Key<P>, VaultId, RecordId); N], target_key: &Key<P>, target_vid: VaultId, target_rid: RecordId, hint: RecordHint, f: F, ) -> Result<T, VaultError<P::Error, E>>
where F: FnOnce([Buffer<u8>; N]) -> Result<(Zeroizing<Vec<u8>>, T), E>, E: Debug,

Access the decrypted Buffers of the specified Records and place the return value into the target Record.

Source

pub fn revoke_record( &mut self, key: &Key<P>, vid: VaultId, rid: RecordId, ) -> Result<(), RecordError<P::Error>>

Add a revocation transaction to the Record

Source

pub fn garbage_collect_vault(&mut self, key: &Key<P>, vid: VaultId)

Garbage collect a Vault. Deletes any records that contain revocation transactions.

Source

pub fn clear(&mut self)

Clears the entire Vault from memory.

Source

pub fn list_vaults(&self) -> Vec<VaultId>

List the ids of all vaults.

Source

pub fn list_records(&self, vid: &VaultId) -> Vec<RecordId>

List the ids of all records in the vault.

Source

pub fn list_records_with_blob_id( &self, key: &Key<P>, vid: VaultId, ) -> Result<Vec<(RecordId, BlobId)>, VaultError<P::Error>>

List RecordId and BlobId of all entries in the vault.

Source

pub fn export_all(&self) -> HashMap<VaultId, Vec<(RecordId, Record)>>

Clone the all records from all vaults without removing them.

Source

pub fn export_records<I>( &self, vid: VaultId, records: I, ) -> Result<Vec<(RecordId, Record)>, VaultError<P::Error>>
where I: IntoIterator<Item = RecordId>,

Clone the specified records from the vault without removing them.

Note: before importing these records to a new vault with DbView::import_records, Record::update_meta has to be called on each Record to re-encrypt it with the target vault’s encryption key.

Source

pub fn import_records( &mut self, old_key: &Key<P>, new_key: &Key<P>, vid: VaultId, records: Vec<(RecordId, Record)>, ) -> Result<(), RecordError<P::Error>>

Import records to the Vault. In case of duplicated records, the existing record is dropped in favor of the new one. Re-encrypt the records with the new key.

Trait Implementations§

Source§

impl<P: Clone + BoxProvider> Clone for DbView<P>

Source§

fn clone(&self) -> DbView<P>

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<P: Default + BoxProvider> Default for DbView<P>

Source§

fn default() -> DbView<P>

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

impl<'de, P> Deserialize<'de> for DbView<P>
where P: Deserialize<'de> + BoxProvider,

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<P> Serialize for DbView<P>

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

Auto Trait Implementations§

§

impl<P> Freeze for DbView<P>

§

impl<P> !RefUnwindSafe for DbView<P>

§

impl<P> Send for DbView<P>
where P: Send,

§

impl<P> Sync for DbView<P>
where P: Sync,

§

impl<P> Unpin for DbView<P>
where P: Unpin,

§

impl<P> UnwindSafe for DbView<P>
where P: UnwindSafe,

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> 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<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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,