Skip to main content

WriteTransaction

Trait WriteTransaction 

Source
pub trait WriteTransaction<'db>: ReadTransaction<'db> + Sized {
    type WriteCursor<'txn, T: Table>: WriteCursor<'txn, T>
       where Self: 'txn;
    type DupWriteCursor<'txn, T: DupTable>: DupWriteCursor<'txn, T>
       where Self: 'txn;

    // Required methods
    fn put_reserve<T: RegularTable>(
        &mut self,
        table: &T,
        key: &T::Key,
        value: &T::Value,
    )
       where T::Value: IntoDatabaseValue;
    fn put<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value);
    fn append<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value);
    fn remove<T: Table>(&mut self, table: &T, key: &T::Key);
    fn remove_item<T: Table>(
        &mut self,
        table: &T,
        key: &T::Key,
        value: &T::Value,
    );
    fn commit(self);
    fn cursor<'txn, T: RegularTable>(
        &'txn self,
        table: &T,
    ) -> Self::WriteCursor<'txn, T>;
    fn dup_cursor<'txn, T: DupTable>(
        &'txn self,
        table: &T,
    ) -> Self::DupWriteCursor<'txn, T>;
    fn clear_table<T: Table>(&mut self, table: &T);

    // Provided method
    fn abort(self) { ... }
}
Expand description

Write-transactions can perform read and write operations on a database.

Required Associated Types§

Source

type WriteCursor<'txn, T: Table>: WriteCursor<'txn, T> where Self: 'txn

Source

type DupWriteCursor<'txn, T: DupTable>: DupWriteCursor<'txn, T> where Self: 'txn

Required Methods§

Source

fn put_reserve<T: RegularTable>( &mut self, table: &T, key: &T::Key, value: &T::Value, )

Puts a key/value pair into the database by copying it into a reserved space in the database. This works best for values that need to be serialized into the reserved space. This method will panic when called on a database with duplicate keys!

Source

fn put<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value)

Puts a key/value pair into the database by passing a reference to a byte slice. This is more efficient than put_reserve if no serialization is needed, and the existing value can be immediately written into the database.

Source

fn append<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value)

Appends a key/value pair to the end of the database. This method is more efficient than put. This operation fails if the key is less than the last key.

Source

fn remove<T: Table>(&mut self, table: &T, key: &T::Key)

Removes the entry with this key from the database. In dup tables, it removes all entries with this key.

Source

fn remove_item<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value)

Removes the entry with this key and value from the database. Only matching entries will be deleted.

Source

fn commit(self)

Commits the changes to the database.

Source

fn cursor<'txn, T: RegularTable>( &'txn self, table: &T, ) -> Self::WriteCursor<'txn, T>

Creates a write cursor for the given table.

Source

fn dup_cursor<'txn, T: DupTable>( &'txn self, table: &T, ) -> Self::DupWriteCursor<'txn, T>

Creates a write cursor for the given duplicate table.

Source

fn clear_table<T: Table>(&mut self, table: &T)

Clears the table of all entries.

Provided Methods§

Source

fn abort(self)

Aborts the transaction and discards all changes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'db> WriteTransaction<'db> for MdbxTransaction<'db, RW>

Source§

type WriteCursor<'txn, T: Table> = MdbxCursor<'txn, RW, T> where 'db: 'txn

Source§

type DupWriteCursor<'txn, T: DupTable> = MdbxCursor<'txn, RW, T> where 'db: 'txn

Source§

impl<'db> WriteTransaction<'db> for MdbxWriteTransaction<'db>

Source§

type WriteCursor<'txn, T: Table> = MdbxCursor<'txn, RW, T> where Self: 'txn

Source§

type DupWriteCursor<'txn, T: DupTable> = MdbxCursor<'txn, RW, T> where Self: 'txn