[−][src]Struct sanakirja::Env
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]
path: P,
length: u64
) -> Result<Env, Error>
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
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,