pub trait Transaction: Get {
// Required methods
fn set(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>);
fn del(&mut self, key: impl AsRef<[u8]>);
fn commit(self);
}Expand description
An ACID transaction.
This transaction implements Get. If this transaction has queued a write to a key, the
retrieved value for that key will be the latest value queued to be written by this transaction.
If this transaction has not queued a write to a key, it’s undefined if the retrieved value is:
A) The value which was written to the key when the transaction was opened (from a snapshot)
B) The value which is currently written to the key (which may have been written to by a
committed transaction during the lifetime of this transaction)
In other words, there’s no guarantee reads are repeatable.
Required Methods§
Sourcefn set(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
fn set(&mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>)
Write a value to this key.
If a concurrent transaction has queued a write to this key, the database MAY panic or exhibit an undefined choice of which transaction’s queued write resolves as the database’s current value for this key.
The implementation MAY panic if the database is corrupt or would become corrupted. If the length of the key or value exceeds internal limits on lengths or the total database size, this may be considered as corruption.
Sourcefn del(&mut self, key: impl AsRef<[u8]>)
fn del(&mut self, key: impl AsRef<[u8]>)
Delete the value from this key.
If no value is stored to this key, this operation is effectively a NOP.
This is considered as a write to this key, with properties as documented by
[Transaction::put].
The implementation MAY panic if the database is corrupt or would become corrupted. If the length of the key exceeds an internal limit on the length of keys, this may be considered as corruption.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Transaction for MemDbTxn<'_>
std only.