Struct redb::WriteTransaction
source · pub struct WriteTransaction<'db> { /* private fields */ }
Expand description
A read/write transaction
Only a single WriteTransaction
may exist at a time
Implementations§
source§impl<'db> WriteTransaction<'db>
impl<'db> WriteTransaction<'db>
sourcepub fn savepoint(&self) -> Result<Savepoint, Error>
pub fn savepoint(&self) -> Result<Savepoint, Error>
Creates a snapshot of the current database state, which can be used to rollback the database
Returns [Error::InvalidSavepoint
], if the transaction is “dirty” (any tables have been openned)
sourcepub fn set_durability(&mut self, durability: Durability)
pub fn set_durability(&mut self, durability: Durability)
Set the desired durability level for writes made in this transaction
Defaults to Durability::Immediate
sourcepub fn open_table<'txn, K: RedbKey + ?Sized, V: RedbValue + ?Sized>(
&'txn self,
definition: TableDefinition<'_, K, V>
) -> Result<Table<'db, 'txn, K, V>, Error>
pub fn open_table<'txn, K: RedbKey + ?Sized, V: RedbValue + ?Sized>(
&'txn self,
definition: TableDefinition<'_, K, V>
) -> Result<Table<'db, 'txn, K, V>, Error>
Open the given table
The table will be created if it does not exist
sourcepub fn open_multimap_table<'txn, K: RedbKey + ?Sized, V: RedbKey + ?Sized>(
&'txn self,
definition: MultimapTableDefinition<'_, K, V>
) -> Result<MultimapTable<'db, 'txn, K, V>, Error>
pub fn open_multimap_table<'txn, K: RedbKey + ?Sized, V: RedbKey + ?Sized>(
&'txn self,
definition: MultimapTableDefinition<'_, K, V>
) -> Result<MultimapTable<'db, 'txn, K, V>, Error>
Open the given table
The table will be created if it does not exist
sourcepub fn delete_table<K: RedbKey + ?Sized, V: RedbValue + ?Sized>(
&self,
definition: TableDefinition<'_, K, V>
) -> Result<bool, Error>
pub fn delete_table<K: RedbKey + ?Sized, V: RedbValue + ?Sized>(
&self,
definition: TableDefinition<'_, K, V>
) -> Result<bool, Error>
Delete the given table
Returns a bool indicating whether the table existed
sourcepub fn delete_multimap_table<K: RedbKey + ?Sized, V: RedbKey + ?Sized>(
&self,
definition: MultimapTableDefinition<'_, K, V>
) -> Result<bool, Error>
pub fn delete_multimap_table<K: RedbKey + ?Sized, V: RedbKey + ?Sized>(
&self,
definition: MultimapTableDefinition<'_, K, V>
) -> Result<bool, Error>
Delete the given table
Returns a bool indicating whether the table existed
sourcepub fn list_tables(&self) -> Result<impl Iterator<Item = String> + '_, Error>
pub fn list_tables(&self) -> Result<impl Iterator<Item = String> + '_, Error>
List all the tables
sourcepub fn list_multimap_tables(
&self
) -> Result<impl Iterator<Item = String> + '_, Error>
pub fn list_multimap_tables(
&self
) -> Result<impl Iterator<Item = String> + '_, Error>
List all the multimap tables
sourcepub fn commit(self) -> Result<(), Error>
pub fn commit(self) -> Result<(), Error>
Commit the transaction
All writes performed in this transaction will be visible to future transactions, and are
durable as consistent with the Durability
level set by Self::set_durability
sourcepub fn abort(self) -> Result<(), Error>
pub fn abort(self) -> Result<(), Error>
Abort the transaction
All writes performed in this transaction will be rolled back
sourcepub fn stats(&self) -> Result<DatabaseStats, Error>
pub fn stats(&self) -> Result<DatabaseStats, Error>
Retrieves information about storage usage in the database