Skip to content

Commit

Permalink
Move out the associated types for MutTxDatastore
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx committed Dec 19, 2024
1 parent d76e12d commit d5baa13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
20 changes: 9 additions & 11 deletions crates/core/src/db/datastore/locking_tx_datastore/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,16 @@ impl Tx for Locking {
impl TxDatastore for Locking {
type IterTx<'a>
= IterTx<'a>
where
Self: 'a;
type IterMutTx<'a>= IterMutTx<'a>
where
Self: 'a;
type IterByColRangeTx<'a, R: RangeBounds<AlgebraicValue>>
= IterByColRangeTx<'a, R>
where
Self: 'a;
type IterByColRangeMutTx<'a, R: RangeBounds<AlgebraicValue>>
= IterByColRangeMutTx<'a, R>
where
Self: 'a;
type IterByColEqTx<'a, 'r>
= IterByColRangeTx<'a, &'r AlgebraicValue>
where
Self: 'a;
type IterByColEqMutTx<'a, 'r>
= IterByColRangeMutTx<'a, &'r AlgebraicValue>
where
Self: 'a;

fn iter_tx<'a>(&'a self, tx: &'a Self::Tx, table_id: TableId) -> Result<Self::IterTx<'a>> {
tx.iter(table_id)
Expand Down Expand Up @@ -416,6 +405,15 @@ impl TxDatastore for Locking {
}

impl MutTxDatastore for Locking {
type IterMutTx<'a>= IterMutTx<'a>
where
Self: 'a;
type IterByColRangeMutTx<'a, R: RangeBounds<AlgebraicValue>> = IterByColRangeMutTx<'a, R>;
type IterByColEqMutTx<'a, 'r>
= IterByColRangeMutTx<'a, &'r AlgebraicValue>
where
Self: 'a;

fn create_table_mut_tx(&self, tx: &mut Self::MutTx, schema: TableSchema) -> Result<TableId> {
tx.create_table(schema)
}
Expand Down
23 changes: 12 additions & 11 deletions crates/core/src/db/datastore/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,24 +350,13 @@ pub trait TxDatastore: DataRow + Tx {
where
Self: 'a;

type IterMutTx<'a>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

type IterByColRangeTx<'a, R: RangeBounds<AlgebraicValue>>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;
type IterByColRangeMutTx<'a, R: RangeBounds<AlgebraicValue>>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;
type IterByColEqTx<'a, 'r>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

type IterByColEqMutTx<'a, 'r>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

fn iter_tx<'a>(&'a self, tx: &'a Self::Tx, table_id: TableId) -> Result<Self::IterTx<'a>>;

fn iter_by_col_range_tx<'a, R: RangeBounds<AlgebraicValue>>(
Expand Down Expand Up @@ -404,6 +393,18 @@ pub trait TxDatastore: DataRow + Tx {
}

pub trait MutTxDatastore: TxDatastore + MutTx {
type IterMutTx<'a>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

type IterByColRangeMutTx<'a, R: RangeBounds<AlgebraicValue>>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

type IterByColEqMutTx<'a, 'r>: Iterator<Item = Self::RowRef<'a>>
where
Self: 'a;

// Tables
fn create_table_mut_tx(&self, tx: &mut Self::MutTx, schema: TableSchema) -> Result<TableId>;
// In these methods, we use `'tx` because the return type must borrow data
Expand Down

0 comments on commit d5baa13

Please sign in to comment.