From da985cc06e4caa7501222dbf54f212536fd42b0c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 18 Dec 2025 18:45:53 +0100 Subject: transaction interface --- database/src/indices/mod.rs | 6 +++--- database/src/indices/order.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'database/src/indices') diff --git a/database/src/indices/mod.rs b/database/src/indices/mod.rs index 5856254..523235e 100644 --- a/database/src/indices/mod.rs +++ b/database/src/indices/mod.rs @@ -4,14 +4,14 @@ Copyright (C) 2025 metamuffin */ -use crate::{backends::KV, table::RowNum}; +use crate::{backends::WriteTransaction, table::RowNum}; use anyhow::Result; pub mod order; pub trait Index { - fn add(&self, db: &dyn KV, row: RowNum, val: &T) -> Result<()>; - fn remove(&self, db: &dyn KV, row: RowNum, val: &T) -> Result<()>; + fn add(&self, db: &mut dyn WriteTransaction, row: RowNum, val: &T) -> Result<()>; + fn remove(&self, db: &mut dyn WriteTransaction, row: RowNum, val: &T) -> Result<()>; fn compare(&self, before: &T, after: &T) -> bool { let _ = (before, after); true diff --git a/database/src/indices/order.rs b/database/src/indices/order.rs index 04fb975..5b7924b 100644 --- a/database/src/indices/order.rs +++ b/database/src/indices/order.rs @@ -4,7 +4,7 @@ Copyright (C) 2025 metamuffin */ -use crate::{backends::KV, indices::Index, table::Table}; +use crate::{backends::WriteTransaction, indices::Index, table::Table}; use anyhow::Result; pub struct OrderIndex { @@ -25,11 +25,11 @@ impl OrderIndex { } } impl Index for OrderIndex { - fn add(&self, db: &dyn KV, id: u64, val: &T) -> Result<()> { + fn add(&self, db: &mut dyn WriteTransaction, id: u64, val: &T) -> Result<()> { db.set(&self.key(id, val), &[])?; Ok(()) } - fn remove(&self, db: &dyn KV, id: u64, val: &T) -> Result<()> { + fn remove(&self, db: &mut dyn WriteTransaction, id: u64, val: &T) -> Result<()> { db.del(&self.key(id, val))?; Ok(()) } -- cgit v1.3