pub struct RwTransaction<'env> { /* private fields */ }
Expand description
An LMDB read-write transaction.
Implementations§
Source§impl<'env> RwTransaction<'env>
impl<'env> RwTransaction<'env>
Sourcepub unsafe fn create_db(
&self,
name: Option<&str>,
flags: DatabaseFlags,
) -> Result<Database>
pub unsafe fn create_db( &self, name: Option<&str>, flags: DatabaseFlags, ) -> Result<Database>
Opens a database in the provided transaction, creating it if necessary.
If name
is None
, then the default database will be opened, otherwise
a named database will be opened. The database handle will be private to
the transaction until the transaction is successfully committed. If the
transaction is aborted the returned database handle should no longer be
used.
Prefer using Environment::create_db
.
§Safety
This function (as well as Environment::open_db
,
Environment::create_db
, and Database::open
) must not be called
from multiple concurrent transactions in the same environment. A
transaction which uses this function must finish (either commit or
abort) before any other transaction may use this function.
Sourcepub fn open_rw_cursor<'txn>(
&'txn mut self,
db: Database,
) -> Result<RwCursor<'txn>>
pub fn open_rw_cursor<'txn>( &'txn mut self, db: Database, ) -> Result<RwCursor<'txn>>
Opens a new read-write cursor on the given database and transaction.
Sourcepub fn put<K, D>(
&mut self,
database: Database,
key: &K,
data: &D,
flags: WriteFlags,
) -> Result<()>
pub fn put<K, D>( &mut self, database: Database, key: &K, data: &D, flags: WriteFlags, ) -> Result<()>
Stores an item into a database.
This function stores key/data pairs in the database. The default
behavior is to enter the new key/data pair, replacing any previously
existing key if duplicates are disallowed, or adding a duplicate data
item if duplicates are allowed (DatabaseFlags::DUP_SORT
).
Sourcepub fn reserve<'txn, K>(
&'txn mut self,
database: Database,
key: &K,
len: size_t,
flags: WriteFlags,
) -> Result<&'txn mut [u8]>
pub fn reserve<'txn, K>( &'txn mut self, database: Database, key: &K, len: size_t, flags: WriteFlags, ) -> Result<&'txn mut [u8]>
Returns a buffer which can be used to write a value into the item at the given key and with the given length. The buffer must be completely filled by the caller.
Sourcepub fn del<K>(
&mut self,
database: Database,
key: &K,
data: Option<&[u8]>,
) -> Result<()>
pub fn del<K>( &mut self, database: Database, key: &K, data: Option<&[u8]>, ) -> Result<()>
Deletes an item from a database.
This function removes key/data pairs from the database. If the database
does not support sorted duplicate data items (DatabaseFlags::DUP_SORT
)
the data parameter is ignored. If the database supports sorted
duplicates and the data parameter is None
, all of the duplicate data
items for the key will be deleted. Otherwise, if the data parameter is
Some
only the matching data item will be deleted. This function will
return Error::NotFound
if the specified key/data pair is not in the
database.
Sourcepub fn clear_db(&mut self, db: Database) -> Result<()>
pub fn clear_db(&mut self, db: Database) -> Result<()>
Empties the given database. All items will be removed.
Sourcepub unsafe fn drop_db(&mut self, db: Database) -> Result<()>
pub unsafe fn drop_db(&mut self, db: Database) -> Result<()>
Drops the database from the environment.
§Safety
This method is unsafe in the same ways as Environment::close_db
, and
should be used accordingly.
Sourcepub fn begin_nested_txn<'txn>(&'txn mut self) -> Result<RwTransaction<'txn>>
pub fn begin_nested_txn<'txn>(&'txn mut self) -> Result<RwTransaction<'txn>>
Begins a new nested transaction inside of this transaction.