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>
impl<K, V> Collection<K, V>
Sourcepub fn open<E: KvEngine>(
engine: &E,
key_provider: Arc<dyn KeyProvider>,
name: impl Into<String>,
schema_version: u32,
) -> StoreResult<Self>
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 with the default write Compression.
Errors with StoreError::CollectionNotFound if no DEK wrapping has
been provisioned. The collection’s sealed-value format (legacy vs
prefixed) was fixed at creation and is read from _collection_formats.
Sourcepub fn open_with<E: KvEngine>(
engine: &E,
key_provider: Arc<dyn KeyProvider>,
name: impl Into<String>,
schema_version: u32,
compression: Compression,
) -> StoreResult<Self>
pub fn open_with<E: KvEngine>( engine: &E, key_provider: Arc<dyn KeyProvider>, name: impl Into<String>, schema_version: u32, compression: Compression, ) -> StoreResult<Self>
Collection::open with an explicit write Compression policy.
The policy affects only what this handle writes (and only on prefixed
collections); reads always honor each row’s own format byte.
Sourcepub fn open_or_create<E: KvEngine>(
engine: &E,
key_provider: Arc<dyn KeyProvider>,
name: impl Into<String>,
schema_version: u32,
) -> StoreResult<Self>
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 with the default write Compression, 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. A collection created here
is prefixed (v2): its rows may compress. An existing collection keeps
the format it was created with.
Sourcepub fn open_or_create_with<E: KvEngine>(
engine: &E,
key_provider: Arc<dyn KeyProvider>,
name: impl Into<String>,
schema_version: u32,
compression: Compression,
) -> StoreResult<Self>
pub fn open_or_create_with<E: KvEngine>( engine: &E, key_provider: Arc<dyn KeyProvider>, name: impl Into<String>, schema_version: u32, compression: Compression, ) -> StoreResult<Self>
Collection::open_or_create with an explicit write Compression
policy. Use Compression::Off for collections whose rows mix
user-secret and attacker-influenced bytes (the length side-channel rule
in crate::compress).
Sourcepub fn schema_version(&self) -> u32
pub fn schema_version(&self) -> u32
The schema version bound into every row’s AAD.
Sourcepub fn get(&self, tx: &impl Readable, key: &K) -> StoreResult<Option<V>>
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.
Sourcepub fn put(&self, tx: &mut impl WriteTx, key: &K, value: &V) -> StoreResult<()>
pub fn put(&self, tx: &mut impl WriteTx, key: &K, value: &V) -> StoreResult<()>
Encrypt and store value under key.