pub trait Env {
fn txn_ro(&self) -> Result<TxnRo<'_>, Error>;
fn clone_ro(&self) -> EnvRo;
fn max_keysize(&self) -> usize;
fn valid_keysize<K>(&self, key: &K) -> bool
where
K: ?Sized + Storable;
unsafe fn open_dbs<'a, K, V, C>(
&self,
options: impl IntoIterator<IntoIter = impl Iterator<Item = &'a DbOptions<K, V, C, Option<CString>>> + ExactSizeIterator>
) -> Result<Vec<Db<K, V, C>>, Error>
where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint;
fn clear_stale_readers(&self) -> Result<(), Error>;
unsafe fn open_db<K, V, C>(
&self,
options: &DbOptions<K, V, C, Option<CString>>
) -> Result<Db<K, V, C>, Error>
where
K: ?Sized + Storable,
V: ?Sized + Storable,
C: Constraint,
{ ... }
}
Expand description
Read-write or read-only handle for accessing environment that stores key-value databases
Use Env::clone_ro
to create a new read-only handle (from either a
read-only or a read-write handle) for accessing the same environment.
The environment is closed when the last handle is dropped.
Use Env::open_db
to retrieve database handles.
To modify data inside a database, a transaction is needed which can be
opened with either Env::txn_ro
(read-only) or EnvRw::txn_rw
(for
reading and writing).
Required Methods
fn max_keysize(&self) -> usize
fn max_keysize(&self) -> usize
Get maximum size of keys and duplicate data
Checks if key or duplicate data has valid size
Open databases in environment
SAFETY: If a database exists already, it must have been created with compatible options.
fn clear_stale_readers(&self) -> Result<(), Error>
fn clear_stale_readers(&self) -> Result<(), Error>
Clear stale readers
Refer to LMDB’s documentation when to clear stale readers
Provided Methods
Open database in environment
SAFETY: If a database exists already, it must have been created with compatible options.