Struct Vault

Source
pub struct Vault<P: BoxProvider> { /* private fields */ }
Expand description

A enclave of data that is encrypted under one Key.

Implementations§

Source§

impl<P: BoxProvider> Vault<P>

Source

pub fn init_vault(key: &Key<P>) -> Vault<P>

Initialize a new Vault

Source

pub fn add_or_update_record( &mut self, key: &Key<P>, id: ChainId, data: &[u8], record_hint: RecordHint, ) -> Result<(), RecordError<P::Error>>

Adds a new Record to the Vault if the Record doesn’t already exist. Otherwise, updates the data in the existing Record as long as it hasn’t been revoked.

Source

pub fn extend<I>( &mut self, key: &Key<P>, entries: I, ) -> Result<(), RecordError<P::Error>>
where I: IntoIterator<Item = (ChainId, Record)>,

Extend the stored entries with entries from another vault with the same key. In case of duplicated records, the existing record is dropped in favor of the new one.

Source

pub fn export_record(&self, rid: &RecordId) -> Option<Record>

Export record stored in the current vault. This clones the encrypted record without removing it.

Source

pub fn revoke( &mut self, key: &Key<P>, id: ChainId, ) -> Result<(), RecordError<P::Error>>

Revokes an Record by its ChainId. Does nothing if the Record doesn’t exist.

Source

pub fn get_guard( &self, key: &Key<P>, id: ChainId, ) -> Result<Buffer<u8>, RecordError<P::Error>>

Gets the decrypted Buffer from the Record

Source

pub fn garbage_collect(&mut self)

Sorts through all of the vault entries and garbage collects any revoked entries.

Source

pub fn get_blob_id( &self, key: &Key<P>, id: ChainId, ) -> Result<BlobId, RecordError<P::Error>>

Gets the BlobId of the record with the given ChainId.

Trait Implementations§

Source§

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

Source§

fn clone(&self) -> Vault<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<'de, P> Deserialize<'de> for Vault<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 Vault<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 Vault<P>

§

impl<P> !RefUnwindSafe for Vault<P>

§

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

§

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

§

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

§

impl<P> UnwindSafe for Vault<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>,