pub struct WriteTransaction { /* private fields */ }
Expand description
A read/write transaction
Only a single WriteTransaction
may exist at a time
Implementations§
Source§impl WriteTransaction
impl WriteTransaction
Sourcepub fn persistent_savepoint(&self) -> Result<u64, SavepointError>
pub fn persistent_savepoint(&self) -> Result<u64, SavepointError>
Creates a snapshot of the current database state, which can be used to rollback the database.
This savepoint will exist until it is deleted with [delete_savepoint()]
.
Note that while a savepoint exists, pages that become unused after it was created are not freed. Therefore, the lifetime of a savepoint should be minimized.
Returns [SavepointError::InvalidSavepoint
], if the transaction is “dirty” (any tables have been opened)
or if the transaction’s durability is less than [Durability::Immediate]
Sourcepub fn get_persistent_savepoint(
&self,
id: u64,
) -> Result<Savepoint, SavepointError>
pub fn get_persistent_savepoint( &self, id: u64, ) -> Result<Savepoint, SavepointError>
Get a persistent savepoint given its id
Sourcepub fn delete_persistent_savepoint(
&self,
id: u64,
) -> Result<bool, SavepointError>
pub fn delete_persistent_savepoint( &self, id: u64, ) -> Result<bool, SavepointError>
Delete the given persistent savepoint.
Note that if the transaction is abort()’ed this deletion will be rolled back.
Returns true
if the savepoint existed
Returns [SavepointError::InvalidSavepoint
] if the transaction’s durability is less than [Durability::Immediate]
Sourcepub fn list_persistent_savepoints(&self) -> Result<impl Iterator<Item = u64>>
pub fn list_persistent_savepoints(&self) -> Result<impl Iterator<Item = u64>>
List all persistent savepoints
Sourcepub fn ephemeral_savepoint(&self) -> Result<Savepoint, SavepointError>
pub fn ephemeral_savepoint(&self) -> Result<Savepoint, SavepointError>
Creates a snapshot of the current database state, which can be used to rollback the database
This savepoint will be freed as soon as the returned [Savepoint]
is dropped.
Returns [SavepointError::InvalidSavepoint
], if the transaction is “dirty” (any tables have been opened)
Sourcepub fn restore_savepoint(
&mut self,
savepoint: &Savepoint,
) -> Result<(), SavepointError>
pub fn restore_savepoint( &mut self, savepoint: &Savepoint, ) -> Result<(), SavepointError>
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
Will panic if the durability is reduced below [Durability::Immediate]
after a persistent savepoint has been created or deleted.
Sourcepub fn open_table<'txn, K: Key + 'static, V: Value + 'static>(
&'txn self,
definition: TableDefinition<'_, K, V>,
) -> Result<Table<'txn, K, V>, TableError>
pub fn open_table<'txn, K: Key + 'static, V: Value + 'static>( &'txn self, definition: TableDefinition<'_, K, V>, ) -> Result<Table<'txn, K, V>, TableError>
Open the given table
The table will be created if it does not exist
Sourcepub fn open_multimap_table<'txn, K: Key + 'static, V: Key + 'static>(
&'txn self,
definition: MultimapTableDefinition<'_, K, V>,
) -> Result<MultimapTable<'txn, K, V>, TableError>
pub fn open_multimap_table<'txn, K: Key + 'static, V: Key + 'static>( &'txn self, definition: MultimapTableDefinition<'_, K, V>, ) -> Result<MultimapTable<'txn, K, V>, TableError>
Open the given table
The table will be created if it does not exist
Sourcepub fn delete_table(
&self,
definition: impl TableHandle,
) -> Result<bool, TableError>
pub fn delete_table( &self, definition: impl TableHandle, ) -> Result<bool, TableError>
Delete the given table
Returns a bool indicating whether the table existed
Sourcepub fn delete_multimap_table(
&self,
definition: impl MultimapTableHandle,
) -> Result<bool, TableError>
pub fn delete_multimap_table( &self, definition: impl MultimapTableHandle, ) -> Result<bool, TableError>
Delete the given table
Returns a bool indicating whether the table existed
Sourcepub fn list_tables(
&self,
) -> Result<impl Iterator<Item = UntypedTableHandle> + '_>
pub fn list_tables( &self, ) -> Result<impl Iterator<Item = UntypedTableHandle> + '_>
List all the tables
Sourcepub fn list_multimap_tables(
&self,
) -> Result<impl Iterator<Item = UntypedMultimapTableHandle> + '_>
pub fn list_multimap_tables( &self, ) -> Result<impl Iterator<Item = UntypedMultimapTableHandle> + '_>
List all the multimap tables
Sourcepub fn commit(self) -> Result<(), CommitError>
pub fn commit(self) -> Result<(), CommitError>
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
pub fn abort(self) -> Result
Abort the transaction
All writes performed in this transaction will be rolled back
Sourcepub fn stats(&self) -> Result<DatabaseStats>
pub fn stats(&self) -> Result<DatabaseStats>
Retrieves information about storage usage in the database
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WriteTransaction
impl !RefUnwindSafe for WriteTransaction
impl Send for WriteTransaction
impl Sync for WriteTransaction
impl Unpin for WriteTransaction
impl !UnwindSafe for WriteTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 704 bytes