[][src]Trait lmdb::Transaction

pub trait Transaction: Sized {
    fn txn(&self) -> *mut MDB_txn;

    fn commit(self) -> Result<()> { ... }
fn abort(self) { ... }
unsafe fn open_db(&self, name: Option<&str>) -> Result<Database> { ... }
fn get<'txn, K>(
        &'txn self,
        database: Database,
        key: &K
    ) -> Result<&'txn [u8]>
    where
        K: AsRef<[u8]>
, { ... }
fn open_ro_cursor<'txn>(&'txn self, db: Database) -> Result<RoCursor<'txn>> { ... }
fn db_flags(&self, db: Database) -> Result<DatabaseFlags> { ... }
fn stat(&self, db: Database) -> Result<Stat> { ... } }

An LMDB transaction.

All database operations require a transaction.

Required methods

fn txn(&self) -> *mut MDB_txn

Returns a raw pointer to the underlying LMDB transaction.

The caller must ensure that the pointer is not used after the lifetime of the transaction.

Loading content...

Provided methods

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

Commits the transaction.

Any pending operations will be saved.

fn abort(self)

Aborts the transaction.

Any pending operations will not be saved.

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

Opens a database in the transaction.

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::open_db.

Safety

This function (as well as Environment::open_db, Environment::create_db, and Database::create) 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.

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

Gets an item from a database.

This function retrieves the data associated with the given key in the database. If the database supports duplicate keys (DatabaseFlags::DUP_SORT) then the first data item for the key will be returned. Retrieval of other items requires the use of Transaction::cursor_get. If the item is not in the database, then Error::NotFound will be returned.

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

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

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

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

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

Retrieves database statistics.

Loading content...

Implementors

impl<'env> Transaction for RoTransaction<'env>[src]

fn commit(self) -> Result<()>[src]

fn abort(self)[src]

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

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

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

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

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

impl<'env> Transaction for RwTransaction<'env>[src]

fn commit(self) -> Result<()>[src]

fn abort(self)[src]

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

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

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

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

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

Loading content...