[][src]Struct sanakirja::Env

pub struct Env<T> { /* 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.

Implementations

impl<T> Env<T>[src]

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

Total size of this environemnt.

impl<T> Env<T>[src]

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

std::fs::File size of the database path, if it exists.

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 unsafe fn new_nolock<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Self, 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.

impl Env<Shared>[src]

pub fn new_shared<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Env<Shared>, 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 fn try_new_shared<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Env<Shared>, Error>
[src]

Initialize an environment. length must be a strictly positive multiple of 4096. Returns an error if the database is locked by another process or thread.

impl Env<Exclusive>[src]

pub fn new<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Env<Exclusive>, 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 fn try_new<P: AsRef<Path>>(
    path: P,
    length: u64
) -> Result<Env<Exclusive>, Error>
[src]

Initialize an environment. length must be a strictly positive multiple of 4096. Returns an error if the database is locked by another process or thread.

pub fn new_anon(length: u64) -> Result<Env<Exclusive>, Error>[src]

Create a new anonymous database, backed by memory. The length is the total size in bytes of the database.

pub fn mut_txn_begin<E: Borrow<Self>>(env: E) -> Result<MutTxn<E, ()>, Error>[src]

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

impl<L> Env<L>[src]

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.

impl<L> Env<L>[src]

pub fn txn_begin<E: Borrow<Self>>(env: E) -> Result<Txn<L, E>, Error>[src]

Start a read-only transaction.

Trait Implementations

impl<T> Drop for Env<T>[src]

impl<T> Send for Env<T>[src]

impl<T> Sync for Env<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Env<T>[src]

impl<T> Unpin for Env<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Env<T> where
    T: UnwindSafe
[src]

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,