aboutsummaryrefslogtreecommitdiff
path: root/database/src/indices/key.rs
diff options
context:
space:
mode:
Diffstat (limited to 'database/src/indices/key.rs')
-rw-r--r--database/src/indices/key.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/database/src/indices/key.rs b/database/src/indices/key.rs
index ab38d71..2790220 100644
--- a/database/src/indices/key.rs
+++ b/database/src/indices/key.rs
@@ -8,18 +8,18 @@ use crate::{
backends::{ReadTransaction, WriteTransaction},
indices::Index,
prefix_iterator::PrefixIterator,
- table::{RowNum, Table, TableNum},
+ table::{RowNum, TableNum},
};
use anyhow::Result;
+use jellycommon::jellyobject::{Object, Tag};
-pub struct KeyIndex<T> {
+pub struct KeyIndex {
id: TableNum,
- key: fn(&T) -> &[u8],
+ key: Vec<Tag>,
}
-impl<T: 'static> KeyIndex<T> {
- pub fn new(table: &mut Table<T>, id: TableNum, key: fn(&T) -> &[u8]) -> Self {
- table.indices.push(Box::new(Self { id, key }));
+impl KeyIndex {
+ pub fn new(id: TableNum, key: Vec<Tag>) -> Self {
Self { id, key }
}
pub fn key(&self, id: RowNum, key: &[u8]) -> Vec<u8> {
@@ -43,15 +43,15 @@ impl<T: 'static> KeyIndex<T> {
})
}
}
-impl<T: 'static> Index<T> for KeyIndex<T> {
- fn add(&self, db: &mut dyn WriteTransaction, id: RowNum, val: &T) -> Result<()> {
- db.set(&self.key(id, (self.key)(val)), &[])
+impl Index for KeyIndex {
+ fn add(&self, db: &mut dyn WriteTransaction, id: RowNum, val: Object) -> Result<()> {
+ // db.set(&self.key(id, (self.key)(val)), &[])
}
- fn remove(&self, db: &mut dyn WriteTransaction, id: RowNum, val: &T) -> Result<()> {
- db.del(&self.key(id, (self.key)(val)))
+ fn remove(&self, db: &mut dyn WriteTransaction, id: RowNum, val: Object) -> Result<()> {
+ // db.del(&self.key(id, (self.key)(val)))
}
- fn compare(&self, before: &T, after: &T) -> bool {
- (self.key)(before) == (self.key)(after)
+ fn compare(&self, before: Object, after: Object) -> bool {
+ // (self.key)(before) == (self.key)(after)
}
}