[][src]Struct sanakirja::Env

pub struct Env { /* fields omitted */ }

Environment, required to start any transactions. Thread-safe, but opening the same database several times in the same process is not cross-platform.

Methods

impl Env[src]

pub fn file_size<P: AsRef<Path>>(path: P) -> Result<u64, Error>[src]

File size of the database path, if it exists.

pub fn size(&self) -> u64[src]

Size of the underlying file. This could be different from self.file_size(), for instance if the environment was opened with a different size than the underlying file size.

pub fn set_flush_limit(&mut self, flush: u64)[src]

Set the maximum number of dirty pages before triggering a flush. The default is 4096 pages. Some operating systems might have other acceptable values. For example, Linux defines the "dirty ratio" as the number of memory pages that have been written to (so-called "dirty pages") divided by number of pages in available memory. This can be checked for instance using the command systctl -a | grep dirty.

pub fn flush_limit(&self) -> u64[src]

Get the maximum number of dirty pages before triggering a flush.

pub fn new<P: AsRef<Path>>(path: P, length: u64) -> Result<Env, Error>[src]

Initialize an environment. length must be a strictly positive multiple of 4096. The same file can only be open in one process or thread at the same time, and this is enforced by a locked file.

pub unsafe fn new_nolock<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Env, Error>
[src]

Same as new, but does not take a lock on the file system.

This method is provided because waiting for a lock on the file system may block the whole process, whereas.

However, the database is very likely to get corrupted if open more than once at the same time, even within the same process.

Therefore, do not use this method without another locking mechanism in place to avoid that situation.

pub fn txn_begin<'env>(&'env self) -> Result<Txn<'env>, Error>[src]

Start a read-only transaction.

pub fn mut_txn_begin<'env>(&'env self) -> Result<MutTxn<'env, ()>, Error>[src]

Start a mutable transaction. Mutable transactions that go out of scope are automatically aborted.

pub unsafe fn close(&mut self)[src]

Close this repository, releasing the locks. It is undefined behaviour to use the environment afterwards. This method can be used for instance to release the locks before allocating a new environment (note that std::mem::replace followed by Drop::drop of the previous value would not release the locks in the correct order).

The safe alternative to this method is to use an Option<Env> instead of an Env.

Trait Implementations

impl Send for Env[src]

impl Drop for Env[src]

impl Sync for Env[src]

Auto Trait Implementations

impl Unpin for Env

impl UnwindSafe for Env

impl !RefUnwindSafe for Env

Blanket Implementations

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.

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

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

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