pub struct Environment<E> where
    E: EnvironmentKind
{ /* private fields */ }
Expand description

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

Implementations

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

Returns a raw pointer to the underlying MDBX environment.

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

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

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.

Flush the environment data buffers to disk.

Retrieves statistics about this environment.

Retrieves info about this environment.

Retrieves the total number of pages on the freelist.

Along with Environment::info(), this can be used to calculate the exact number of used pages as well as free pages in this environment.

let dir = tempfile::tempdir().unwrap();
let env = Environment::<NoWriteMap>::new().open(dir.path()).unwrap();
let info = env.info().unwrap();
let stat = env.stat().unwrap();
let freelist = env.freelist().unwrap();
let last_pgno = info.last_pgno() + 1; // pgno is 0 based.
let total_pgs = info.map_size() / stat.page_size() as usize;
let pgs_in_use = last_pgno - freelist;
let pgs_free = total_pgs - pgs_in_use;

Note:

  • LMDB stores all the freelists in the designated database 0 in each environment, and the freelist count is stored at the beginning of the value as libc::size_t in the native byte order.

  • It will create a read transaction to traverse the freelist database.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.