pub trait OpenTables<'env> {
type Ro<'tx>;
type Rw<'tx>;
// Required methods
fn open_tables(
&self,
tx_ro: &Self::Ro<'_>,
) -> Result<impl TablesIter, RuntimeError>;
fn open_tables_mut(
&self,
tx_rw: &Self::Rw<'_>,
) -> Result<impl TablesMut, RuntimeError>;
fn create_tables(&self, tx_rw: &Self::Rw<'_>) -> Result<(), RuntimeError>;
}
Expand description
Open all tables at once.
This trait encapsulates the functionality of opening all tables at once.
It can be seen as the “constructor” for the Tables
object.
Note that this is already implemented on cuprate_database::EnvInner
, thus:
- You don’t need to implement this
- It can be called using
env_inner.open_tables()
notation
§Creation before opening
As cuprate_database::EnvInner
documentation states,
tables must be created before they are opened.
I.e. OpenTables::create_tables
must be called before
OpenTables::open_tables
or else panics may occur.
Required Associated Types§
Required Methods§
Sourcefn open_tables(
&self,
tx_ro: &Self::Ro<'_>,
) -> Result<impl TablesIter, RuntimeError>
fn open_tables( &self, tx_ro: &Self::Ro<'_>, ) -> Result<impl TablesIter, RuntimeError>
Open all tables in read/iter mode.
This calls cuprate_database::EnvInner::open_db_ro
on all database tables
and returns a structure that allows access to all tables.
§Errors
This will only return cuprate_database::RuntimeError::Io
if it errors.
Sourcefn open_tables_mut(
&self,
tx_rw: &Self::Rw<'_>,
) -> Result<impl TablesMut, RuntimeError>
fn open_tables_mut( &self, tx_rw: &Self::Rw<'_>, ) -> Result<impl TablesMut, RuntimeError>
Open all tables in read-write mode.
This calls cuprate_database::EnvInner::open_db_rw
on all database tables
and returns a structure that allows access to all tables.
§Errors
This will only return cuprate_database::RuntimeError::Io
on errors.
Sourcefn create_tables(&self, tx_rw: &Self::Rw<'_>) -> Result<(), RuntimeError>
fn create_tables(&self, tx_rw: &Self::Rw<'_>) -> Result<(), RuntimeError>
Create all database tables.
This will create all the defined Table
s.
§Errors
This will only return cuprate_database::RuntimeError::Io
on errors.
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.