diff options
Diffstat (limited to 'base/src/database.rs')
-rw-r--r-- | base/src/database.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/base/src/database.rs b/base/src/database.rs index 3971c62..9d29adb 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -10,6 +10,7 @@ use jellycommon::{ ExtendedNode, Node, }; use log::info; +use redb::{Database, TableDefinition}; use serde::{Deserialize, Serialize}; use std::{borrow::Borrow, fs::create_dir_all, ops::Deref, path::Path, sync::RwLock}; use tantivy::{ @@ -18,7 +19,7 @@ use tantivy::{ DateOptions, Index, IndexReader, IndexWriter, ReloadPolicy, }; -pub use redb::*; +pub use redb; pub use tantivy; pub const T_USER: TableDefinition<&str, Ser<User>> = TableDefinition::new("user"); @@ -127,11 +128,11 @@ pub trait TableExt<Key, KeyRef, Value> { fn remove(self, db: &DataAcid, key: KeyRef) -> anyhow::Result<Option<Value>>; } impl<'a, 'b, 'c, Key, Value, KeyRef> TableExt<Key, KeyRef, Value> - for TableDefinition<'a, Key, Ser<Value>> + for redb::TableDefinition<'a, Key, Ser<Value>> where - Key: Borrow<<Key as RedbValue>::SelfType<'b>> + redb::RedbKey, + Key: Borrow<<Key as redb::Value>::SelfType<'b>> + redb::Key, Value: Encode + Decode + std::fmt::Debug + Serialize + for<'x> Deserialize<'x>, - KeyRef: Borrow<<Key as redb::RedbValue>::SelfType<'c>>, + KeyRef: Borrow<<Key as redb::Value>::SelfType<'c>>, { fn get(self, db: &DataAcid, key: KeyRef) -> anyhow::Result<Option<Value>> { let txn = db.inner.begin_read()?; @@ -160,8 +161,8 @@ where // pub trait TableIterExt< // 'a, -// Key: redb::RedbKey + 'static, -// Value: redb::RedbValue + 'static, +// Key: redb::redb::Key + 'static, +// Value: redb::redb::Value + 'static, // F: FnOnce(&redb::Range<'a, Key, Value>) -> anyhow::Result<T>, // T: 'static, // > @@ -171,8 +172,8 @@ where // impl<'a, Key, Value, F, T> TableIterExt<'a, Key, Value, F, T> // for TableDefinition<'static, Key, Value> // where -// Key: redb::RedbKey, -// Value: redb::RedbValue, +// Key: redb::redb::Key, +// Value: redb::redb::Value, // F: FnOnce(&redb::Range<'a, Key, Value>) -> anyhow::Result<T>, // T: 'static, // { @@ -192,7 +193,7 @@ where #[cfg(not(feature = "db_json"))] pub struct Ser<T>(pub T); #[cfg(not(feature = "db_json"))] -impl<T: Encode + Decode + std::fmt::Debug> RedbValue for Ser<T> { +impl<T: Encode + Decode + std::fmt::Debug> redb::Value for Ser<T> { type SelfType<'a> = Ser<T> where Self: 'a; @@ -222,7 +223,7 @@ impl<T: Encode + Decode + std::fmt::Debug> RedbValue for Ser<T> { } fn type_name() -> redb::TypeName { - TypeName::new("bincode") + redb::TypeName::new("bincode") } } @@ -230,7 +231,7 @@ impl<T: Encode + Decode + std::fmt::Debug> RedbValue for Ser<T> { #[cfg(feature = "db_json")] pub struct Ser<T>(pub T); #[cfg(feature = "db_json")] -impl<T: Serialize + for<'a> Deserialize<'a> + std::fmt::Debug> RedbValue for Ser<T> { +impl<T: Serialize + for<'a> Deserialize<'a> + std::fmt::Debug> redb::Value for Ser<T> { type SelfType<'a> = Ser<T> where Self: 'a; @@ -258,6 +259,6 @@ impl<T: Serialize + for<'a> Deserialize<'a> + std::fmt::Debug> RedbValue for Ser } fn type_name() -> redb::TypeName { - TypeName::new("json") + redb::TypeName::new("json") } } |