mmtkvdb
is a crate for Rust which provides a memory-mapped key-value
database. It uses LMDB and links with an existing liblmdb
on the system.
Because of how memory-mapped I/O is being used and also because of certain
assumptions of the underlying LMDB API, opening environments and databases
requires unsafe
Rust (i.e. the programmer must ensure that certain
preconditions are met that cannot be enforced by the compiler to avoid
undefined behavior). If you aim to program in safe Rust only, this Rust
library is not suitable for you.
For documentation on how to use this crate, refer to the example in
src/lib.rs
.
See contained LICENSE
file (MIT License).
Env
was removed. Instead, EnvRw
implements
Deref<Target=EnvRo>
, which makes all methods of EnvRo
available on
EnvRw
as well. Converting an EnvRw
into EnvRo
is now simply done by
cloning.TxnRw::cursor_delete_current
and
TxnRw::cursor_delete_current_key
did not properly defer closing the
affected databases. This might have caused database corruption when the
cursor and (all clones of) the database handle are dropped before the
transaction commits or aborts. This has been fixed.rustc 1.62.0-nightly (77652b9ef 2022-05-06)
(the unused macro rules are
kept for potential future use).TxnRw
contained a misleading (partial)
paragraph which was removed.DbOptions::keys_unique
, DbOptions::keys_duplicate
,
DbOptions::has_duplicate_keys
, TxnRw::put
,
TxnRw::put_unless_key_exists
, TxnRw::put_unless_pair_exists
.DbBackend
has been extended to explain
the mechanism of TxnRw::used_dbs
, which defers closing of
databases.TxnBackend::close_cursors
will finish closing the cursor
before releasing the lock on the CursorBackend::closed
flag (this
should not affect runtime behavior).EnvRo
is now used in some places where EnvBackend
has been used
internally (this allows implementing Deref<Target=EnvRo>
for
EnvRw
).'static
bound from Storable
traitunsafe
use of this librarycursor_set_key_search_value_get_value
, which was wrongly
defined and documentedcore::ffi::{c_size_t, c_int, c_uint}
for now instead of using
std::ffi
(see
commit 07ea143f96
in Rust
for explanation)EnvRo::txn
moved to Env
trait and renamed to Env::txn_ro
.EnvRw::txn
renamed to EnvRw::txn_rw
.EnvRo
and EnvRw
(doc comment explains how
to create them now, i.e. how to start a transaction)PhantomData
to store unit-like structs which indicate
constraints on key uniqueness in DbOptions
and Db
(KeysUnique
and
KeysDuplicate
are Copy
now and contained directly)DbOptions
to Env::open_dbs
Sized
in doc comment on private trait IsType
storable
module doesn't use transmute
on
references anymore. Instead, std::slice::from_raw_parts
,
std::str::from_utf8_unchecked
, and str::as_bytes()
are used.Storable
, StorableConstBytesLen
, and StorableWithOwned
traits
to new (public) storable
module (but Storable
gets re-exported by
crate-level module)u8
and i8
bool
storable (i.e. implement Storable
for bool
)IsType
trait to helpers
module)