pub trait EnvInner<'env> {
type Ro<'tx>: TxRo<'tx>;
type Rw<'tx>: TxRw<'tx>;
// Required methods
fn tx_ro(&self) -> DbResult<Self::Ro<'_>>;
fn tx_rw(&self) -> DbResult<Self::Rw<'_>>;
fn open_db_ro<T: Table>(
&self,
tx_ro: &Self::Ro<'_>,
) -> DbResult<impl DatabaseRo<T> + DatabaseIter<T>>;
fn open_db_rw<T: Table>(
&self,
tx_rw: &Self::Rw<'_>,
) -> DbResult<impl DatabaseRw<T>>;
fn create_db<T: Table>(&self, tx_rw: &Self::Rw<'_>) -> DbResult<()>;
fn clear_db<T: Table>(&self, tx_rw: &mut Self::Rw<'_>) -> DbResult<()>;
}Expand description
The inner Env type.
This type is created with Env::env_inner and represents
the type able to generate transactions and open tables.
§Locking behavior
As noted in Env::env_inner, this is a RwLockReadGuard
when using the heed backend, be aware of this and do
not hold onto an EnvInner for a long time.
§Tables
Note that when opening tables with EnvInner::open_db_ro,
they must be created first or else it will return error.
See EnvInner::create_db for creating tables.
§Invariant
The first time you open/create tables, you must use EnvInner::create_db
to set the proper flags / Key comparison for the heed backend.
Subsequent table opens will follow the flags/ordering, but only if
EnvInner::create_db was the first function to open/create it.
Required Associated Types§
Required Methods§
Sourcefn tx_rw(&self) -> DbResult<Self::Rw<'_>>
fn tx_rw(&self) -> DbResult<Self::Rw<'_>>
Create a read/write transaction.
§Errors
This will only return crate::RuntimeError::Io if it errors.
Sourcefn open_db_ro<T: Table>(
&self,
tx_ro: &Self::Ro<'_>,
) -> DbResult<impl DatabaseRo<T> + DatabaseIter<T>>
fn open_db_ro<T: Table>( &self, tx_ro: &Self::Ro<'_>, ) -> DbResult<impl DatabaseRo<T> + DatabaseIter<T>>
Open a database in read-only mode.
The returned value can have DatabaseRo
& DatabaseIter functions called on it.
This will open the database Table
passed as a generic to this function.
let db = env_inner.open_db_ro::<Table>(&tx_ro);
// ^ ^
// database table table metadata
// (name, key/value type)§Errors
This will only return crate::RuntimeError::Io on normal errors.
If the specified table is not created upon before this function is called,
this will return crate::RuntimeError::TableNotFound.
§Invariant
The first time you open/create tables, you must use EnvInner::create_db
to set the proper flags / Key comparison for the heed backend.
Subsequent table opens will follow the flags/ordering, but only if
EnvInner::create_db was the first function to open/create it.
Sourcefn open_db_rw<T: Table>(
&self,
tx_rw: &Self::Rw<'_>,
) -> DbResult<impl DatabaseRw<T>>
fn open_db_rw<T: Table>( &self, tx_rw: &Self::Rw<'_>, ) -> DbResult<impl DatabaseRw<T>>
Open a database in read/write mode.
All DatabaseRo functions are also callable
with the returned DatabaseRw structure.
Note that DatabaseIter functions are not
available to DatabaseRw structures.
This will open the database Table
passed as a generic to this function.
§Errors
This will only return crate::RuntimeError::Io on errors.
§Invariant
The first time you open/create tables, you must use EnvInner::create_db
to set the proper flags / Key comparison for the heed backend.
Subsequent table opens will follow the flags/ordering, but only if
EnvInner::create_db was the first function to open/create it.
Sourcefn create_db<T: Table>(&self, tx_rw: &Self::Rw<'_>) -> DbResult<()>
fn create_db<T: Table>(&self, tx_rw: &Self::Rw<'_>) -> DbResult<()>
Create a database table.
This will create the database Table passed as a generic to this function.
§Errors
This will only return crate::RuntimeError::Io on errors.
§Invariant
The first time you open/create tables, you must use EnvInner::create_db
to set the proper flags / Key comparison for the heed backend.
Subsequent table opens will follow the flags/ordering, but only if
EnvInner::create_db was the first function to open/create it.
Sourcefn clear_db<T: Table>(&self, tx_rw: &mut Self::Rw<'_>) -> DbResult<()>
fn clear_db<T: Table>(&self, tx_rw: &mut Self::Rw<'_>) -> DbResult<()>
Clear all (key, value)’s from a database table.
This will delete all key and values in the passed
T: Table, but the table itself will continue to exist.
Note that this operation is tied to tx_rw, as such this
function’s effects can be aborted using TxRw::abort.
§Errors
This will return crate::RuntimeError::Io on normal errors.
If the specified table is not created upon before this function is called,
this will return crate::RuntimeError::TableNotFound.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.