Skip to main content

Collection

Struct Collection 

Source
pub struct Collection<K, V> { /* private fields */ }
Expand description

An encrypted, typed collection. Rows are AEAD-sealed under a per-collection DEK; see the module docs for the trust model.

Implementations§

Source§

impl<K, V> Collection<K, V>

Source

pub fn open<E: KvEngine>( engine: &E, key_provider: Arc<dyn KeyProvider>, name: impl Into<String>, schema_version: u32, ) -> StoreResult<Self>

Open an existing collection. Errors with StoreError::CollectionNotFound if no DEK wrapping has been provisioned.

Source

pub fn open_or_create<E: KvEngine>( engine: &E, key_provider: Arc<dyn KeyProvider>, name: impl Into<String>, schema_version: u32, ) -> StoreResult<Self>

Open a collection, provisioning a fresh DEK on first use. The check and the create happen in one write transaction, so a collection is never double-provisioned with conflicting DEKs by a concurrent opener.

Source

pub fn name(&self) -> &str

The collection’s name (its table name).

Source

pub fn schema_version(&self) -> u32

The schema version bound into every row’s AAD.

Source

pub fn get(&self, tx: &impl Readable, key: &K) -> StoreResult<Option<V>>

Fetch and decrypt the value for key, or None if absent. A missing row returns None without touching the vault — only a present row requires an unlock to decrypt.

Source

pub fn put(&self, tx: &mut impl WriteTx, key: &K, value: &V) -> StoreResult<()>

Encrypt and store value under key.

Source

pub fn delete(&self, tx: &mut impl WriteTx, key: &K) -> StoreResult<bool>

Remove key. Returns true if a value was present. No key material is needed to delete a ciphertext row.

Source

pub fn range( &self, tx: &impl Readable, lo: &K, hi: &K, ) -> StoreResult<Vec<(K, V)>>

Decrypt and return the (key, value) pairs in [lo, hi), in ascending logical key order. The DEK is unwrapped once for the whole scan.

Trait Implementations§

Source§

impl<K, V> Debug for Collection<K, V>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V> !RefUnwindSafe for Collection<K, V>

§

impl<K, V> !UnwindSafe for Collection<K, V>

§

impl<K, V> Freeze for Collection<K, V>

§

impl<K, V> Send for Collection<K, V>

§

impl<K, V> Sync for Collection<K, V>

§

impl<K, V> Unpin for Collection<K, V>

§

impl<K, V> UnsafeUnpin for Collection<K, V>

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> 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, 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