Struct lmdb::Environment[][src]

pub struct Environment { /* fields omitted */ }

An LMDB environment.

An environment supports multiple databases, all residing in the same shared-memory map.

Implementations

impl Environment[src]

pub fn new() -> EnvironmentBuilder[src]

Creates a new builder for specifying options for opening an LMDB environment.

pub fn env(&self) -> *mut MDB_env[src]

Returns a raw pointer to the underlying LMDB environment.

The caller must ensure that the pointer is not dereferenced after the lifetime of the environment.

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

Opens a handle to an LMDB database.

If name is None, then the returned handle will be for the default database.

If name is not None, then the returned handle will be for a named database. In this case the environment must be configured to allow named databases through EnvironmentBuilder::set_max_dbs.

The returned database handle may be shared among any transaction in the environment.

This function will fail with Error::BadRslot if called by a thread which has an ongoing transaction.

The database name may not contain the null character.

pub fn create_db<'env>(
    &'env self,
    name: Option<&str>,
    flags: DatabaseFlags
) -> Result<Database>
[src]

Opens a handle to an LMDB database, creating the database if necessary.

If the database is already created, the given option flags will be added to it.

If name is None, then the returned handle will be for the default database.

If name is not None, then the returned handle will be for a named database. In this case the environment must be configured to allow named databases through EnvironmentBuilder::set_max_dbs.

The returned database handle may be shared among any transaction in the environment.

This function will fail with Error::BadRslot if called by a thread with an open transaction.

pub fn get_db_flags<'env>(&'env self, db: Database) -> Result<DatabaseFlags>[src]

Retrieves the set of flags which the database is opened with.

The database must belong to to this environment.

pub fn begin_ro_txn<'env>(&'env self) -> Result<RoTransaction<'env>>[src]

Create a read-only transaction for use with the environment.

pub fn begin_rw_txn<'env>(&'env self) -> Result<RwTransaction<'env>>[src]

Create a read-write transaction for use with the environment. This method will block while there are any other read-write transactions open on the environment.

pub fn sync(&self, force: bool) -> Result<()>[src]

Flush data buffers to disk.

Data is always written to disk when Transaction::commit is called, but the operating system may keep it buffered. LMDB always flushes the OS buffers upon commit as well, unless the environment was opened with MDB_NOSYNC or in part MDB_NOMETASYNC.

pub unsafe fn close_db(&mut self, db: Database)[src]

Closes the database handle. Normally unnecessary.

Closing a database handle is not necessary, but lets Transaction::open_database reuse the handle value. Usually it's better to set a bigger EnvironmentBuilder::set_max_dbs, unless that value would be large.

Safety

This call is not mutex protected. Databases should only be closed by a single thread, and only if no other threads are going to reference the database handle or one of its cursors any further. Do not close a handle if an existing transaction has modified its database. Doing so can cause misbehavior from database corruption to errors like Error::BadValSize (since the DB name is gone).

pub fn stat(&self) -> Result<Stat>[src]

Retrieves statistics about this environment.

Trait Implementations

impl Debug for Environment[src]

impl Drop for Environment[src]

impl Send for Environment[src]

impl Sync for Environment[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.