lmdb

Struct RwTransaction

Source
pub struct RwTransaction<'env> { /* private fields */ }
Expand description

An LMDB read-write transaction.

Implementations§

Source§

impl<'env> RwTransaction<'env>

Source

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.

Source

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.

Source

pub fn put<K, D>( &mut self, database: Database, key: &K, data: &D, flags: WriteFlags, ) -> Result<()>
where K: AsRef<[u8]>, D: AsRef<[u8]>,

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).

Source

pub fn reserve<'txn, K>( &'txn mut self, database: Database, key: &K, len: size_t, flags: WriteFlags, ) -> Result<&'txn mut [u8]>
where K: AsRef<[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.

Source

pub fn del<K>( &mut self, database: Database, key: &K, data: Option<&[u8]>, ) -> Result<()>
where K: AsRef<[u8]>,

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.

Source

pub fn clear_db(&mut self, db: Database) -> Result<()>

Empties the given database. All items will be removed.

Source

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.

Source

pub fn begin_nested_txn<'txn>(&'txn mut self) -> Result<RwTransaction<'txn>>

Begins a new nested transaction inside of this transaction.

Trait Implementations§

Source§

impl<'env> Debug for RwTransaction<'env>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'env> Drop for RwTransaction<'env>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'env> Transaction for RwTransaction<'env>

Source§

fn txn(&self) -> *mut MDB_txn

Returns a raw pointer to the underlying LMDB transaction. Read more
Source§

fn commit(self) -> Result<()>

Commits the transaction. Read more
Source§

fn abort(self)

Aborts the transaction. Read more
Source§

unsafe fn open_db(&self, name: Option<&str>) -> Result<Database>

Opens a database in the transaction. Read more
Source§

fn get<'txn, K>(&'txn self, database: Database, key: &K) -> Result<&'txn [u8]>
where K: AsRef<[u8]>,

Gets an item from a database. Read more
Source§

fn open_ro_cursor<'txn>(&'txn self, db: Database) -> Result<RoCursor<'txn>>

Open a new read-only cursor on the given database.
Source§

fn db_flags(&self, db: Database) -> Result<DatabaseFlags>

Gets the option flags for the given database in the transaction.
Source§

fn stat(&self, db: Database) -> Result<Stat>

Retrieves database statistics.

Auto Trait Implementations§

§

impl<'env> Freeze for RwTransaction<'env>

§

impl<'env> RefUnwindSafe for RwTransaction<'env>

§

impl<'env> !Send for RwTransaction<'env>

§

impl<'env> !Sync for RwTransaction<'env>

§

impl<'env> Unpin for RwTransaction<'env>

§

impl<'env> UnwindSafe for RwTransaction<'env>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.