Trait cuprate_blockchain::tables::OpenTables

source ·
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§

source

type Ro<'tx>

The read-only transaction type of the backend.

source

type Rw<'tx>

The read-write transaction type of the backend.

Required Methods§

source

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.

source

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.

source

fn create_tables(&self, tx_rw: &Self::Rw<'_>) -> Result<(), RuntimeError>

Create all database tables.

This will create all the defined Tables.

§Errors

This will only return cuprate_database::RuntimeError::Io on errors.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'env, Ei> OpenTables<'env> for Ei
where Ei: EnvInner<'env>,

source§

type Ro<'tx> = <Ei as EnvInner<'env>>::Ro<'tx>

source§

type Rw<'tx> = <Ei as EnvInner<'env>>::Rw<'tx>