Struct EnvBuilder

Source
pub struct EnvBuilder { /* private fields */ }
Expand description

Handle on an uninitialised LMDB environment to allow configuring pre-open options.

Implementations§

Source§

impl EnvBuilder

Source

pub fn new() -> Result<Self>

Allocates a new, uninitialised environment.

Source

pub fn set_mapsize(&mut self, size: usize) -> Result<()>

Set the size of the memory map to use for this environment.

The size should be a multiple of the OS page size. The default is 10485760 bytes. The size of the memory map is also the maximum size of the database. The value should be chosen as large as possible, to accommodate future growth of the database.

The new size takes effect immediately for the current process but will not be persisted to any others until a write transaction has been committed by the current process. Also, only mapsize increases are persisted into the environment.

See also Environment::set_mapsize().

Source

pub fn set_maxreaders(&mut self, readers: u32) -> Result<()>

Set the maximum number of threads/reader slots for the environment.

This defines the number of slots in the lock table that is used to track readers in the the environment. The default is 126. Starting a read-only transaction normally ties a lock table slot to the current thread until the environment closes or the thread exits. If NOTLS is in use, starting a transaction instead ties the slot to the transaction object until it or the Environment object is destroyed.

Source

pub fn set_maxdbs(&mut self, dbs: u32) -> Result<()>

Set the maximum number of named databases for the environment.

This function is only needed if multiple databases will be used in the environment. Simpler applications that use the environment as a single unnamed database can ignore this option.

Currently a moderate number of slots are cheap but a huge number gets expensive: 7-120 words per transaction, and every mdb_dbi_open() does a linear search of the opened slots.

Source

pub unsafe fn open( self, path: &str, flags: Flags, mode: FileMode, ) -> Result<Environment>

Opens the file or directory at path with the given flags and, on UNIX, permissions given by mode.

path is a &str for convenience, and must be convertable to a CString. The non-use of &OsStr or AsRef<Path> as normally used in std is deliberate, since the path must be convertable to a byte string. But as a result there is no way to address files whose names are not valid UTF-8 through this call.

§Unsafety

It is the caller’s responsibility to ensure that the underlying file will be used properly. Since LMDB is built on memory-mapping, these responsibilities run quite deep and vary based on flags.

  • The caller must ensure that no other process writes to the file in any way except going through LMDB. If this is violated, segfaults can occur, or immutable references can be observed to have their referent mutated asynchronously.

  • If the caller uses flags which suppress locking, the caller must additionally ensure that LMDB’s locking requirements are upheld.

  • If the caller uses flags that result in the creation of a sparse file, the caller must ensure there is actually sufficient disk space for all pages of the file or else a segfault may occur.

Trait Implementations§

Source§

impl Debug for EnvBuilder

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> SafeBorrow<T> for T
where T: ?Sized,

Source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
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.