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§
type WriteCursor<'txn, T: Table>: WriteCursor<'txn, T> where Self: 'txn
type DupWriteCursor<'txn, T: DupTable>: DupWriteCursor<'txn, T> where Self: 'txn
Required Methods§
Sourcefn put_reserve<T: RegularTable>(
&mut self,
table: &T,
key: &T::Key,
value: &T::Value,
)where
T::Value: IntoDatabaseValue,
fn put_reserve<T: RegularTable>(
&mut self,
table: &T,
key: &T::Key,
value: &T::Value,
)where
T::Value: IntoDatabaseValue,
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!
Sourcefn put<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value)
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.
Sourcefn append<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)
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.
Sourcefn remove<T: Table>(&mut self, table: &T, key: &T::Key)
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.
Sourcefn remove_item<T: Table>(&mut self, table: &T, key: &T::Key, value: &T::Value)
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.
Sourcefn cursor<'txn, T: RegularTable>(
&'txn self,
table: &T,
) -> Self::WriteCursor<'txn, T>
fn cursor<'txn, T: RegularTable>( &'txn self, table: &T, ) -> Self::WriteCursor<'txn, T>
Creates a write cursor for the given table.
Sourcefn dup_cursor<'txn, T: DupTable>(
&'txn self,
table: &T,
) -> Self::DupWriteCursor<'txn, T>
fn dup_cursor<'txn, T: DupTable>( &'txn self, table: &T, ) -> Self::DupWriteCursor<'txn, T>
Creates a write cursor for the given duplicate table.
Sourcefn clear_table<T: Table>(&mut self, table: &T)
fn clear_table<T: Table>(&mut self, table: &T)
Clears the table of all entries.
Provided Methods§
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.