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>
impl<P: BoxProvider> DbView<P>
Sourcepub fn init_vault(&mut self, key: &Key<P>, vid: VaultId)
pub fn init_vault(&mut self, key: &Key<P>, vid: VaultId)
Initialize a new Vault if it doesn’t exist.
Sourcepub fn write(
&mut self,
key: &Key<P>,
vid: VaultId,
rid: RecordId,
data: &[u8],
record_hint: RecordHint,
) -> Result<(), RecordError<P::Error>>
pub fn write( &mut self, key: &Key<P>, vid: VaultId, rid: RecordId, data: &[u8], record_hint: RecordHint, ) -> Result<(), RecordError<P::Error>>
Sourcepub fn list_hints_and_ids(
&self,
key: &Key<P>,
vid: VaultId,
) -> Vec<(RecordId, RecordHint)>
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.
Sourcepub fn contains_vault(&self, vid: &VaultId) -> bool
pub fn contains_vault(&self, vid: &VaultId) -> bool
Check to see if a vault with the given VaultId is present.
Sourcepub fn contains_record(&self, vid: VaultId, rid: RecordId) -> bool
pub fn contains_record(&self, vid: VaultId, rid: RecordId) -> bool
Sourcepub fn get_blob_id(
&self,
key: &Key<P>,
vid: VaultId,
rid: RecordId,
) -> Result<BlobId, VaultError<P::Error>>
pub fn get_blob_id( &self, key: &Key<P>, vid: VaultId, rid: RecordId, ) -> Result<BlobId, VaultError<P::Error>>
Sourcepub fn get_guard<T, E, F>(
&self,
key: &Key<P>,
vid: VaultId,
rid: RecordId,
f: F,
) -> Result<T, VaultError<P::Error, E>>
pub fn get_guard<T, E, F>( &self, key: &Key<P>, vid: VaultId, rid: RecordId, f: F, ) -> Result<T, VaultError<P::Error, E>>
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>>
Sourcepub 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>>
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>>
Sourcepub fn revoke_record(
&mut self,
key: &Key<P>,
vid: VaultId,
rid: RecordId,
) -> Result<(), RecordError<P::Error>>
pub fn revoke_record( &mut self, key: &Key<P>, vid: VaultId, rid: RecordId, ) -> Result<(), RecordError<P::Error>>
Add a revocation transaction to the Record
Sourcepub fn garbage_collect_vault(&mut self, key: &Key<P>, vid: VaultId)
pub fn garbage_collect_vault(&mut self, key: &Key<P>, vid: VaultId)
Garbage collect a Vault. Deletes any records that contain revocation transactions.
Sourcepub fn list_vaults(&self) -> Vec<VaultId>
pub fn list_vaults(&self) -> Vec<VaultId>
List the ids of all vaults.
Sourcepub fn list_records(&self, vid: &VaultId) -> Vec<RecordId>
pub fn list_records(&self, vid: &VaultId) -> Vec<RecordId>
List the ids of all records in the vault.
Sourcepub fn list_records_with_blob_id(
&self,
key: &Key<P>,
vid: VaultId,
) -> Result<Vec<(RecordId, BlobId)>, VaultError<P::Error>>
pub fn list_records_with_blob_id( &self, key: &Key<P>, vid: VaultId, ) -> Result<Vec<(RecordId, BlobId)>, VaultError<P::Error>>
Sourcepub fn export_all(&self) -> HashMap<VaultId, Vec<(RecordId, Record)>>
pub fn export_all(&self) -> HashMap<VaultId, Vec<(RecordId, Record)>>
Clone the all records from all vaults without removing them.
Sourcepub fn export_records<I>(
&self,
vid: VaultId,
records: I,
) -> Result<Vec<(RecordId, Record)>, VaultError<P::Error>>where
I: IntoIterator<Item = RecordId>,
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.
Sourcepub fn import_records(
&mut self,
old_key: &Key<P>,
new_key: &Key<P>,
vid: VaultId,
records: Vec<(RecordId, Record)>,
) -> Result<(), RecordError<P::Error>>
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.