cuprate_txpool::tables

Trait 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.

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.

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>