Struct mmtkvdb::EnvBuilder

source ·
pub struct EnvBuilder<P> { /* private fields */ }
Expand description

Options for opening an environment

This struct follows the builder pattern. Start with EnvBuilder::new and open the environment with EnvBuilder::open_ro (for read-only access) or EnvBuilder::open_rw (for read-write access).

Caveats / Safety

Do not open the same environment twice in the same process.

Since this cannot be easily ensured (and because the environment must be free of corruption on the storage medium), open_ro and open_rw are marked as unsafe. Use EnvRo::clone to (re-)open an already open environment in read-only mode.

The file format is platform specific, so endianness and word size must not change across use.

Example

// question mark operator may return with `std::io::Error`
use mmtkvdb::{self as kv, Txn as _};
use tempfile::tempdir;
let location = tempdir()?;
let env_builder = kv::EnvBuilder::new().dir(location.path()).max_dbs(1);
let mut env_rw = unsafe { env_builder.open_rw() }?;
let env_ro = env_rw.clone(); // clones `EnvRo` due to deref coercion

Implementations§

Default options for environment

Set directory location

Set file location

Get writable memory map option

Set or clear writable memory map option

Enabling the writable memory map is incompatible with nested transactions (see TxnRw::nested).

Get no-meta-sync option

Set or clear no-meta-sync option

Get maximum environment size

Set maximum environment size

Get maximum number of concurrent readers

Set maximum number of concurrent readers

Get maximum number of named databases

Set maximum number of named databases

Get file mode

Set file mode

Check if transactions are nestable with current options

See TxnRw::nested.

Open environment in read-only mode

Safety
  • Do not open the same environment twice in the same process.
  • The environment must be free of corruption on the storage medium.
  • The file format is platform specific, so endianness and word size must not change across use.

Open environment in read-write mode

Safety
  • Do not open the same environment twice in the same process.
  • The environment must be free of corruption on the storage medium.
  • The file format is platform specific, so endianness and word size must not change across use.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.